0

我正在尝试运行并发库,但我遇到了一些命令问题。我正在使用这个: https ://www.npmjs.com/package/concurrently

我在我的服务器上尝试更改 package.json:

 "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start":"node index.js",
    "server": "nodemon index.js",
    "client": "cd client && npm run serve",
    "dev": "concurrently \"nodemon index.js\" \"npm run serve\""
  },

我有 2 个单独的目录:服务器和客户端

在此处输入图像描述

当我尝试“npm run dev”时,我得到:

[0] [nodemon] 2.0.3
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching path(s): *.*
[0] [nodemon] watching extensions: js,mjs,json
[0] [nodemon] starting `node index.js`
[1] npm ERR! missing script: serve
[1] npm ERR!
[1] npm ERR! Did you mean this?
[1] npm ERR!     server
[1] 
[1] npm ERR! A complete log of this run can be found in:
[1] npm ERR!     C:\Users\David\AppData\Roaming\npm-cache\_logs\2020-06-14T14_51_57_124Z-debug.log
[1] npm run serve exited with code 1
[0] Sever started on port 3000
4

1 回答 1

1

服务可能是在客户端目录中定义的,因此您需要先 cd 那里。

"dev": "concurrently \"nodemon index.js\" \"cd client && npm run serve\""
于 2020-06-14T15:29:03.837 回答