簡體   English   中英

無法將“節點”識別為內部或外部命令,可操作程序或批處理文件

[英]'node' is not recognized as an internal or external command, operable program or batch file

我正在Windows 10的git-bash-cli中運行“ npm install node-sass”,得到的“節點”未被識別為內部或外部命令,可操作程序或批處理文件。 錯誤。

我使用此設置已有多年,而將節點升級到10.16.0時問題就開始了

為避免不必要的答復:

我所看到的所有問題都只是說要添加path變量。

我已經將Node添加到PATH變量中,並嘗試了多種不同的編寫方式。 我最后重新安裝了Node.js,它會自動執行,因此就這樣了。

節點從命令行運行,而不是從腳本運行,例如package.json文件中的腳本。

我嘗試重新安裝節點8.11.3,這是問題開始之前我所使用的版本,但是遇到相同的錯誤。 我再次回到v 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 ,它解決了這個問題

感謝所有幫助的人,希望這可以幫助其他人

我認為您必須將node.js的路徑添加到系統變量中

首先:打開控制面板->系統和安全->系統->高級系統設置->環境變量

第二:在“用戶變量”或“系統變量”中找到變量PATH並添加node.js文件夾路徑作為值。它是C:\\ Program Files \\ nodejs;如果不存在,則創建它。

第三:重新啟動計算機。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM