gpt4 book ai didi

javascript - “node”不被识别为内部或外部命令、可操作程序或批处理文件

转载 作者:行者123 更新时间:2023-12-02 23:15:11 27 4
gpt4 key购买 nike

我在 Windows 10 中从 git-bash-cli 运行“npm install node-sass”并收到“‘node’未被识别为内部或外部命令,可运行的程序或批处理文件。”错误。

我已经使用此设置多年,当我将 Node 升级到 10.16.0 时,问题就开始了

为了防止不必要的回复:

我看到的所有问题都只是说添加路径变量。

我已将 Node 添加到 PATH 变量中,并尝试了多种不同的编写方式。我最终重新安装了 Node.js,它会自动完成,所以我就保持原样。

Node 从命令行运行,而不是从脚本运行,如 package.json 文件中的脚本。

我尝试重新安装 Node 8.11.3,这是问题出现之前我使用的版本,但我收到了相同的错误。我又回到了 10.16.0 版本。

错误代码如下:


> node-sass@4.12.0 install C:\projects\true\true\website\truevue\node_modules\node-sass
> node scripts/install.js

'node' is not recognized as an internal or external command,
operable program or batch file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.0.7 (node_modules\@nuxt\builder\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.0.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.12.0 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.12.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Peter\AppData\Roaming\npm-cache\_logs\2019-07-24T23_41_06_896Z-debug.log

这是我在我正在处理的 Vue 项目上运行 npm run dev 时的日志

1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\Peter\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'dev' ]
2 info using npm@6.10.2-next.1
3 info using node@v10.16.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle thisistrue.co@1.0.0~predev: thisistrue.co@1.0.0
6 info lifecycle thisistrue.co@1.0.0~dev: thisistrue.co@1.0.0
7 verbose lifecycle thisistrue.co@1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle thisistrue.co@1.0.0~dev: PATH: C:\Users\Peter\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\projects\true\true\website\truevue\node_modules\.bin
9 verbose lifecycle thisistrue.co@1.0.0~dev: CWD: C:\projects\true\true\website\truevue
10 silly lifecycle thisistrue.co@1.0.0~dev: Args: [ '/d /s /c',
10 silly lifecycle 'cross-env NODE_ENV=development nodemon server/index.js --watch server' ]
11 silly lifecycle thisistrue.co@1.0.0~dev: Returned: code: 1 signal: null
12 info lifecycle thisistrue.co@1.0.0~dev: Failed to exec dev script
13 verbose stack Error: thisistrue.co@1.0.0 dev: `cross-env NODE_ENV=development nodemon server/index.js --watch server`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Users\Peter\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:317:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\Peter\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid thisistrue.co@1.0.0
15 verbose cwd C:\projects\true\true\website\truevue
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Peter\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
18 verbose node v10.16.0
19 verbose npm v6.10.2-next.1
20 error code ELIFECYCLE
21 error errno 1
22 error thisistrue.co@1.0.0 dev: `cross-env NODE_ENV=development nodemon server/index.js --watch server`
22 error Exit status 1
23 error Failed at the thisistrue.co@1.0.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

最佳答案

终于找到这个问题的答案了。我最终所做的就是运行 npm update -g 并解决了问题

感谢所有提供帮助的人,希望这可以帮助其他人

关于javascript - “node”不被识别为内部或外部命令、可操作程序或批处理文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57192634/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com