为什么“ npm run <command>”在任何地方都不起作用?

时间:2019-12-25 14:55:59

标签: node.js npm

npm run在任何项目上均不起作用。因此,我无法将软件包安装在有例如后安装脚本的地方

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'test'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v13.5.0
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle myapp@0.0.0~pretest: myapp@0.0.0
6 info lifecycle myapp@0.0.0~test: myapp@0.0.0
7 verbose lifecycle myapp@0.0.0~test: unsafe-perm in lifecycle true
8 verbose lifecycle myapp@0.0.0~test: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Vombat\Desktop\Learn\express_template_app\myapp\node_modules\.bin;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Users\Vombat\AppData\Local\Microsoft\WindowsApps;C:\Users\Vombat\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Vombat\AppData\Roaming\npm
9 verbose lifecycle myapp@0.0.0~test: CWD: C:\Users\Vombat\Desktop\Learn\express_template_app\myapp
10 silly lifecycle myapp@0.0.0~test: Args: [ '-c', 'node -v' ]
11 info lifecycle myapp@0.0.0~test: Failed to exec test script
12 silly lifecycle myapp@0.0.0~test: Returned: code: -4058  signal: null
13 info lifecycle myapp@0.0.0~test: Failed to exec test script
14 verbose stack Error: myapp@0.0.0 test: `node -v`
14 verbose stack spawn = ENOENT
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
14 verbose stack     at onErrorNT (internal/child_process.js:469:16)
14 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:84:21)
15 verbose pkgid myapp@0.0.0
16 verbose cwd C:\Users\Vombat\Desktop\Learn\express_template_app\myapp
17 verbose Windows_NT 10.0.18362
18 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
19 verbose node v13.5.0
20 verbose npm  v6.13.4
21 error code ELIFECYCLE
22 error syscall spawn =
23 error file =
24 error path =
25 error errno -4058
26 error myapp@0.0.0 test: `node -v`
26 error spawn = ENOENT
27 error Failed at the myapp@0.0.0 test script.
27 error This is probably not a problem with npm. There is likely additional logging output above.
28 verbose exit [ -4058, true ]

我将节点更新为最新版本,尝试了npm cache clear --forcenpm cache verify,但没有帮助。 操作系统Windows 10。 节点版本13.5.0,npm版本6.13.4

1 个答案:

答案 0 :(得分:0)

确保正确设置了NODE_PATH环境变量。 路径必须匹配您的nodeJS目录+ \node_modules

enter image description here