当我使用npm运行任何脚本时,无论在哪个项目中,都会出现错误。
例如,当我运行npm run start
时,出现以下错误:
nasteas-MacBook-Pro:newapp nastea$ npm run start
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/nastea/.npm/_logs/2020-01-02T19_28_32_592Z-debug.log
这是我的 package.json 文件:
{
"name": "01-first-app",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"amocrm-api": "^1.3.1"
}
}
这些是日志:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'start' ]
2 info using npm@6.13.4
3 info using node@v12.14.0
4 verbose stack Error: missing script: start
4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:155:19)
4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:63:5
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:116:5
4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:436:5
4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:391:45)
4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:434:3)
4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:161:5)
4 verbose stack at ReadFileContext.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:350:20)
4 verbose stack at ReadFileContext.callback (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:115:16)
4 verbose stack at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:239:13)
5 verbose cwd /Users/nastea/Downloads/nodejs-basics-tutorial-master/01-first-app/newapp
6 verbose Darwin 17.7.0
7 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start"
8 verbose node v12.14.0
9 verbose npm v6.13.4
10 error missing script: start
11 verbose exit [ 1, true ]
我尝试了以下操作:
1.卸载并重新安装节点。
2. npm config get ignore-scripts
返回false
有什么解决方案?任何帮助将不胜感激。
稍后编辑:节点也不在终端中运行任何.js文件。
编辑:run start
现在可以使用。