8

I have just initialized a new project with Node.js and trying making the scripts in package.json file to be working.

For example I have the next package.json file:

{
  "name": "my-app-name",
  "version": "1.0.0",
  "description": "Description server",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node app.js"
  },
  "author": "Something LTD",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.18.3",
    "cron": "^1.3.0",
    "crypto": "^1.0.1",
    "docusaurus-init": "^1.0.2",
    "exceljs": "^1.5.0",
    "express": "^4.16.3",
    "express-limiter": "^1.6.1",
    "jsonwebtoken": "^8.3.0",
    "mongojs": "^2.6.0",
    "npm": "^6.1.0",
    "point-in-polygon": "^1.0.1",
    "request": "^2.87.0",
    "socket.io": "^2.1.1",
    "socket.io-redis": "^5.2.0",
    "xmldom": "^0.1.27"
  },
  "devDependencies": {
    "t4u": "^1.0.0"
  }
}

Then I either trying run npm test or npm start or npm run start but all of them just doing nothing and returns nothing in console. Even the test script just not printing anything.

I have tried to do:

npm config set --ignore-scripts false

However that did not work.

Raz Buchnik
  • 7,753
  • 14
  • 53
  • 96
  • Can you check your version of node: `node -v` And check version of npm `npm -v` – user2590928 Jul 12 '18 at 20:51
  • @user2590928 My version of node is: v9.2.0 and npm version 6.1.0 – Raz Buchnik Jul 12 '18 at 20:52
  • Can you post the code in app.js - It may be possible that the code is running but your app is not coded to do anything - This could explain why you see no errors – user2590928 Jul 12 '18 at 20:59
  • I have just commented all of the code and wrote just some console.log which get displayed on terminal when doing node app.js but not on npm start – Raz Buchnik Jul 12 '18 at 21:01
  • What happens if you run `npm run test`? – user2590928 Jul 12 '18 at 21:12
  • Nothing. BTW when I am changing the "name" to something that includes spaces, like this: app name (notice the space) I receive the next error: Invalid name: "taxi4you server" npm ERR! A complete log of this run can be found in: npm ERR! /Users/razbuchnik/.npm/_logs/2018-07-13T04_17_10_092Z-debug.log razs-MacBook:server razbuchnik$ – Raz Buchnik Jul 13 '18 at 04:17

3 Answers3

28
npm config set ignore-scripts false

Was solved the issue.

Bertrand P
  • 820
  • 7
  • 24
Raz Buchnik
  • 7,753
  • 14
  • 53
  • 96
3

npm run-script start worked for me (npm run is an alias to npm run-script as stated in doc but not sure why alias didnt work)

hope this helps people who are still facing the issue after setting ignore-script as false

RGog
  • 96
  • 12
1

On Windows you can also edit directly a file on the following location

C:\Users\[Your username]\.npmrc

and set ignore-scripts=false

theshinylight
  • 233
  • 4
  • 8