简体   繁体   English

如何使用MacOS在package.json上调用多个命令

[英]How to call multiple commands on package.json using MacOS

I'm migrating my project from Windows to MacOS. 我正在将项目从Windows迁移到MacOS。 Here is the script I have in Windows, inside package.json: 这是我在Windows中的package.json中的脚本:

"start-dev": "nodemon --exec \"set NODE_ENV=development && cd ./src && babel-node server.js",

How do I write that under MacOS ? 我如何在MacOS上编写该代码? This is what I've tried with no success: 这是我尝试未成功的尝试:

"start-dev": "nodemon --exec \"NODE_ENV=development cd ./src babel-node server.js",

Using Windows like command I'm getting the following error: 使用类似Windows的命令时,出现以下错误:

$ yarn start-dev
yarn run v1.6.0
(node:6638) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
$ nodemon --exec "set NODE_ENV=development && cd ./src && babel-node server.js
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

You should be able to write the same command under macOs. 您应该能够在macO下编写相同的命令。

"start-dev": "nodemon --exec \"set NODE_ENV=development && cd ./src && babel-node server.js",

The above commands should work on MacOS. 以上命令应在MacOS上运行。 If not please tell us what is the error you get. 如果没有,请告诉我们您遇到的错误是什么。

EDIT: You don't close your quotes: I think you want to do that (added a quote at the end): 编辑:您不要关闭引号:我想您想要这样做(在末尾添加引号):

"start-dev": "nodemon --exec \"set NODE_ENV=development && cd ./src && babel-node server.js\"",

尝试一下,假设您不熟悉bash:

export NODE_ENV=development && cd src && nohup babel-node server.js &

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM