2017-01-25 3 views
2

Ich habe ein Problem mit NPM. In letzter Zeit, wenn ich versuche, Skripte mit npm ausführen es gibt mir eine ganze Wand von Fehlern, auch wenn ich weiß, dass die Skripte korrekt sind und ich kann nicht herausfinden, warum ...Npm-Lauf gibt immer Fehler beim Versuch, Skripte auszuführen

package.json

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

Wie Sie das sehen kann, ist gerade erzeugt direkt nach npm init läuft und nur paar mal schlagen geben ... und doch, wenn ich npm run test betreibe ich diese bekommen ...

> [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 

Wie Sie in der Fehlermeldung angezeigt , Ich habe Knoten v7.4.0 und npm v4.1.2 ... Vorher ich war Knoten V6.9.2 ausgeführt, aber ich aktualisiert nach dem Erhalt dieses Fehlers und immer noch keine Änderung ... Auch ich weiß nicht, ob es viel ausmacht oder nicht, aber ich habe Windows 10. Ich habe bereits versucht, die npm cache clear Lösung, aber das hat bei mir nicht funktioniert.

Antwort

4

Das ist normal, wenn Sie npm run test ausführen, wird es das entsprechende Skript in package.json, so dass diese Zeile ausführen

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

Wie Sie sehen können, es hebt und Fehler und Ausgang mit einem Statuscode anders als 0 (exit 1), was ein Fehlercode ist.

Sie müssen das Testskript durch etwas anderes ändern, das wirklich Tests durchführt.

+0

Ich sehe ... danke dafür .. es funktioniert jetzt, aber es warf Fehler zurück, als ich versuchte, webpack-dev-server über Npm-Skript zu laufen ... ist es möglich, weil ich nicht das Neueste hatte Versionen von Knoten und NPM? – Kirito

+1

Es kann, aber es kann auch ein Konfigurationsproblem sein. Um Knotenversionen einfach zu verwalten, empfehle ich Ihnen, [nvm] (https://github.com/creationix/nvm) zu verwenden. Wenn das Problem weiterhin besteht, öffnen Sie eine neue Frage mit weiteren Details zu Ihrer Konfiguration – ThomasThiebaud

Verwandte Themen