package.json 中的 npm 不是 运行 脚本

npm not running scripts in package.json

问题是,当我执行 npm startnpm run customScriptCommand npm 时,只是没有对项目做任何事情,很快就 return 终端中的新行。

我试过从我的机器上删除节点和 npm,然后为节点和 npm 执行 brew 安装,但它没有解决问题。

然后我尝试从 brew 安装中删除节点和 npm,然后从 nvm 重新安装它,但它也没有解决问题。

NPM 详细信息

npm -v -> 6.11.3
which npm -> /usr/local/bin/npm

NodeJS 详细信息

node -v -> v12.12.0
which node ->/usr/local/bin/node

package.json

中的脚本
"scripts": {
    "start": "node ./bin/www",
    "devstart": "DEBUG=app-name:* nodemon ./bin/www", //I've changed my actual app name to "app-name"
  },

如果我这样做 node ./bin/wwwDEBUG=app-name:* nodemon ./bin/www 它将起作用:

更新

{
   "name": "test"
   "version": "1.0.0",
   "description": "",
   "main": "index.js",
   "scripts": {
       "test": "echo \"Error: no test specified\" && exit 1"
   },
   "keywords": [],
   "author": "itsme",
   "license": "ISC"
}

你可以安装 yarn 并且它可以工作;只是 运行 yarn start。至于是什么导致了这个问题,我不知道。

npm config set ignore-scripts false 会为您效劳。

我的朋友,斗争是真实的,从现在开始不要跟随随机教程。

https://github.com/npm/cli/issues/541

安装 npm install --save-dev nodemon 和 运行 npm start 对我来说很神奇