【问题标题】:How can i run concurrently node.js and Vue?如何同时运行 node.js 和 Vue?
【发布时间】:2020-06-14 15:08:29
【问题描述】:

我正在尝试运行并发库,但我遇到了一些命令问题。我正在使用这个: 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

【问题讨论】:

  • serve 未在scripts 中定义,因此missing script: serve。应该是concurrently \"npm run server\" \"npm run client\"

标签: node.js vue.js concurrently


【解决方案1】:

Serve 可能是在客户端目录中定义的,所以你需要先 cd 到那里。

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

【讨论】:

    猜你喜欢
    • 2019-07-16
    • 2017-09-30
    • 2022-01-15
    • 1970-01-01
    • 2020-05-17
    • 2019-09-18
    • 1970-01-01
    • 2018-12-16
    • 2020-07-20
    相关资源
    最近更新 更多