【问题标题】:node start error in WindowsWindows 中的节点启动错误
【发布时间】:2018-10-14 19:49:45
【问题描述】:

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"
  }
}

【问题讨论】:

    标签: node.js windows mean


    【解决方案1】:

    您的start 脚本缺少cross-env。将您的 package.json 更改为:

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

    它已在debug 脚本中使用。

    注意它也不属于依赖项,因此必须通过npm i cross-env --save 添加。

    【讨论】:

    • "cross-env" 不是内部或外部命令、可执行程序或批处理文件。 npm 错误!代码 ELIFECYCLE npm 错误! errno 1 npm 错误! nodejs-starter@1.0.0 开始:cross-env SECRET=diplom nodemon index.js npm ERR!退出状态 1 npm ERR! npm 错误!在 nodejs-starter@1.0.0 启动脚本中失败。 npm 错误!这可能不是 npm 的问题。上面可能还有额外的日志输出。
    • 需要添加到package.jsonnpm i cross-env --save
    猜你喜欢
    • 2023-04-07
    • 2022-01-07
    • 1970-01-01
    • 2017-02-16
    • 2013-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-10
    相关资源
    最近更新 更多