Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm run always gives error when trying to run scripts

Tags:

node.js

npm

I have a problem with NPM. Lately, whenever I try to run scripts with npm it gives me an entire wall of errors, even when I know the scripts are correct and I can not figure out why...

package.json

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

As you can see this is just generated right after running npm init and just hitting enter couple of times... and yet when I run npm run test I get this...

> [email protected] test C:\Users\user\Desktop\testing
> echo "Error: no test specified" && exit 1

"Error: no test specified"

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
npm ERR! node v7.4.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test: `echo "Error: no test specified" && exit 1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script 'echo "Error: no test specified" && exit 1'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the testing package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     echo "Error: no test specified" && exit 1
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs testing
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls testing
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\user\Desktop\testing\npm-debug.log

As you can see in the error message, I have node v7.4.0 and npm v4.1.2... Previously I was running node v6.9.2, but I updated after getting this error and still no change... Also I don't know whether it matters much or not, but I am running windows 10. I have already tried the npm cache clear solution, but that did not work for me.

like image 681
Reel Avatar asked Jan 25 '17 12:01

Reel


1 Answers

This is normal, when you run npm run test, it will execute the corresponding script in package.json, so this line

"test": "echo \"Error: no test specified\" && exit 1"

As you can see, it raises and error and exit with a status code different than 0 (exit 1), which is an error code.

You must change the test script by something else that really run tests.

like image 184
ThomasThiebaud Avatar answered Sep 21 '22 21:09

ThomasThiebaud