git-bash执行npm命令提示'"node"' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

环境变量已经配置过了,我使用cmd进行操作就可以,使用bash就会提示这个,npm install是可以正常运行的,错误日志提示如下
项目1:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'D:\\nodejs\\node.exe',
1 verbose cli   'D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'upall'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v12.14.1
4 verbose run-script [ 'preupall', 'upall', 'postupall' ]
5 info lifecycle hexo-site@0.0.0~preupall: hexo-site@0.0.0
6 info lifecycle hexo-site@0.0.0~upall: hexo-site@0.0.0
7 verbose lifecycle hexo-site@0.0.0~upall: unsafe-perm in lifecycle true
8 verbose lifecycle hexo-site@0.0.0~upall: PATH: D:\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;F:\whiteS18.github.io\node_modules\.bin;D:\Git\mingw64\bin;D:\Git\usr\bin;C:\Users\SCW\bin;F:\whiteS18.github.io\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;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)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;D:\Java\jdk1.8.0_241\bin;D:\Java\jdk1.8.0_241\jre\bin;.;D:\apache-maven-3.6.2\bin";D:\nodejs;D:\Git\mingw64\libexec\git-core;D:\Git\usr\bin;C:\Windows\system3;.;C:\Windows;C:\Windows\System32\Wbem;C:\Users\SCW\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Bandizip;D:\Microsoft VS Code\bin;D:\JetBrains\IntelliJ IDEA 2019.3.1\bin;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Users\SCW\AppData\Local\BypassRuntm;C:\Users\SCW\AppData\Roaming\npm;D:\nodejs
9 verbose lifecycle hexo-site@0.0.0~upall: CWD: F:\whiteS18.github.io
10 silly lifecycle hexo-site@0.0.0~upall: Args: [
10 silly lifecycle   '/d /s /c',
10 silly lifecycle   'cross-env hexo cl && hexo g && gulp && hexo d && git add . && git commit -m " quick update" && git push origin source '
10 silly lifecycle ]
11 silly lifecycle hexo-site@0.0.0~upall: Returned: code: 9009  signal: null
12 info lifecycle hexo-site@0.0.0~upall: Failed to exec upall script
13 verbose stack Error: hexo-site@0.0.0 upall: `cross-env hexo cl && hexo g && gulp && hexo d && git add . && git commit -m " quick update" && git push origin source `
13 verbose stack Exit status 9009
13 verbose stack     at EventEmitter.<anonymous> (D:\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:223:5)
13 verbose stack     at ChildProcess.<anonymous> (D:\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:223:5)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid hexo-site@0.0.0
15 verbose cwd F:\whiteS18.github.io
16 verbose Windows_NT 10.0.18362
17 verbose argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "upall"
18 verbose node v12.14.1
19 verbose npm  v6.13.4
20 error code ELIFECYCLE
21 error errno 9009
22 error hexo-site@0.0.0 upall: `cross-env hexo cl && hexo g && gulp && hexo d && git add . && git commit -m " quick update" && git push origin source `
22 error Exit status 9009
23 error Failed at the hexo-site@0.0.0 upall script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 9009, true ]

项目2:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'D:\\nodejs\\node.exe',
1 verbose cli   'D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'serve'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v12.14.1
4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
5 info lifecycle cwsong@0.1.0~preserve: cwsong@0.1.0
6 info lifecycle cwsong@0.1.0~serve: cwsong@0.1.0
7 verbose lifecycle cwsong@0.1.0~serve: unsafe-perm in lifecycle true
8 verbose lifecycle cwsong@0.1.0~serve: PATH: D:\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;F:\cwsong\node_modules\.bin;D:\Git\mingw64\bin;D:\Git\usr\bin;C:\Users\SCW\bin;F:\cwsong\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;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)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;D:\Java\jdk1.8.0_241\bin;D:\Java\jdk1.8.0_241\jre\bin;.;D:\apache-maven-3.6.2\bin";D:\nodejs;D:\Git\mingw64\libexec\git-core;D:\Git\usr\bin;C:\Windows\system3;.;C:\Windows;C:\Windows\System32\Wbem;C:\Users\SCW\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Bandizip;D:\Microsoft VS Code\bin;D:\JetBrains\IntelliJ IDEA 2019.3.1\bin;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Users\SCW\AppData\Local\BypassRuntm;C:\Users\SCW\AppData\Roaming\npm;D:\nodejs
9 verbose lifecycle cwsong@0.1.0~serve: CWD: F:\cwsong
10 silly lifecycle cwsong@0.1.0~serve: Args: [ '/d /s /c', 'vue-cli-service serve' ]
11 silly lifecycle cwsong@0.1.0~serve: Returned: code: 9009  signal: null
12 info lifecycle cwsong@0.1.0~serve: Failed to exec serve script
13 verbose stack Error: cwsong@0.1.0 serve: `vue-cli-service serve`
13 verbose stack Exit status 9009
13 verbose stack     at EventEmitter.<anonymous> (D:\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:223:5)
13 verbose stack     at ChildProcess.<anonymous> (D:\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:223:5)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid cwsong@0.1.0
15 verbose cwd F:\cwsong
16 verbose Windows_NT 10.0.18362
17 verbose argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "serve"
18 verbose node v12.14.1
19 verbose npm  v6.13.4
20 error code ELIFECYCLE
21 error errno 9009
22 error cwsong@0.1.0 serve: `vue-cli-service serve`
22 error Exit status 9009
23 error Failed at the cwsong@0.1.0 serve script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 9009, true ]

这两个命令我通过cmd去执行是可以正常执行的
我的node,npm版本如下

SCW@DESKTOP-73RCKME MINGW64 ~/Desktop
$ node -v
v12.14.1

SCW@DESKTOP-73RCKME MINGW64 ~/Desktop
$ npm -v
6.13.4

SCW@DESKTOP-73RCKME MINGW64 ~/Desktop
$

请问该怎么解决呢???

阅读 13.2k
4 个回答

目前又可以用了,我的操作是:

  1. 卸载git和nodejs
  2. 找到nodejs安装的位置,看文件夹是否还在,还在就删除掉
  3. 下载最新git的nodejsLTS版本.在这里下载
  4. 因为我之前的文件夹已经删除了,所以需要设置node全局目录,设置淘宝镜像源重新安装组件(这个根据需要来,百度教程很多)
新手上路,请多包涵

请问楼主是怎么解决的啊?我是直接而提示:'node' 不是内部或外部命令,也不是可运行的程序或批处理文件。

楼主怎么解决的? 我的也一样 ,就git bash 中有问题cmd没有问题我的天 这是什么鬼

你的环境变量没有在git-bash生效!使其生效即可。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏