我如何 运行 同时 node.js 和 Vue?

How can i run concurrently node.js and Vue?

我正在尝试 运行 并发库,但我在使用命令时遇到了一些麻烦。我正在使用这个: 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\_logs20-06-14T14_51_57_124Z-debug.log
[1] npm run serve exited with code 1
[0] Sever started on port 3000

Serve 可能定义在客户端目录中,因此您需要先 cd 到那里。

"dev": "concurrently \"nodemon index.js\" \"cd client && npm run serve\""