Windows中的节点启动错误

时间:2018-05-04 10:39:49

标签: node.js windows mean

Windows MEVN堆栈项目 我有npm start终端输出:

$ npm start

> nodejs-starter@1.0.0 start C:\final-dip\diplom-master
> SECRET=diplom nodemon index.js

"SECRET" is not internal or external
command, executable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nodejs-starter@1.0.0 start: `SECRET=diplom nodemon index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodejs-starter@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2018-05-04T10_33_19_073Z-debug.log
package.json中的

代码:

{
  "name": "nodejs-starter",
  "version": "1.0.0",
  "description": "A boilerplate for NodeJS web servers",
  "main": "index.js",
  "scripts": {
    "start": "SECRET=diplom nodemon index.js",
    "init": "node ./controllers/init",
    "debug": "cross-env PORT=3333 SECRET=GREEN_BUS nodemon --inspect index.js"
  },
  "keywords": [],
  "author": "Almat Ybray",
  "license": "MIT",
  "devDependencies": {
    "eslint": "^4.14.0",
    "nodemon": "^1.14.7"
  },
  "dependencies": {
    "async": "^2.6.0",
    "body-parser": "^1.18.2",
    "cookie-parser": "^1.4.3",
    "cors": "^2.8.4",
    "express": "^4.16.2",
    "express-jwt": "^5.3.1",
    "express-validator": "^5.0.3",
    "helmet": "^3.9.0",
    "jsonwebtoken": "^8.2.0",
    "mongoose": "^5.0.0-rc1",
    "morgan": "^1.9.0",
    "multer": "^1.3.0",
    "passport": "^0.4.0",
    "passport-local": "^1.0.0",
    "socket.io": "^2.0.4"
  }
}

1 个答案:

答案 0 :(得分:0)

您的cross-env脚本遗失了start。将您的package.json更改为:

{
  "scripts": {
    "start": "cross-env SECRET=diplom nodemon index.js"
  }
}

它已在debug脚本中使用。

注意它也不是依赖项的一部分,因此必须通过npm i cross-env --save添加。