Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
321 views
in Technique[技术] by (71.8m points)

javascript - npm not running scripts in package.json

The problem is that when I do npm start OR npm run customScriptCommand npm just not doing anything with the project and quickly just return new line in the terminal.

I've tried removing node and npm from my machine and then do brew installation for node and npm, but it does not fix the problem.

Then I tried removing node and npm from the brew installation and installing it again from nvm, but it also does not fix the problem.

NPM Details

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

NodeJS Details

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

Scripts in package.json

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

If I do node ./bin/www OR DEBUG=app-name:* nodemon ./bin/www it will work:

enter image description here

Update

  • I've tried on other project that does not have problem on my colleague's machine, with git clone do npm install and tried to run the project, but it still failed

  • Even with fresh project which I just did npm init -y it fail,

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

npm config set ignore-scripts false would do the trick for you.

The struggle is real my friend, not following random tutorials from now.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...