我的NPM安装似乎有问题。我在Windows 10上,我有npm v6.0.0
请参阅此示例package.json文件的脚本:
"nodev": "node -v",
"npmv": "npm -v"
"gulpv": "gulp -v",
"gulp2v": "./node_modules/gulp/bin/gulp.js -v"
以下是运行上述内容的输出:
npm run nodev
:'node' is not recognized as an internal or external command
npm run npmv
:'npm' is not recognized as an internal or external command
npm run gulpv
:'node' is not recognized as an internal or external command
npm run gulp2v
:'.' is not recognized as an internal or external command
现在,如果我在不经过npm的情况下运行命令:
node -v
:v10.0.0
npm -v
:6.0.0
gulp -v
:[22:55:15] CLI version 1.2.1 (\n) [22:55:15] Local version 3.9.1
./node_modules/gulp/bin/gulp.js -v
:[22:55:56] CLI version 3.9.1 (\n) [22:55:56] Local version 3.9.1
我的PATH环境变量设置正确,因为我可以在不通过NPM脚本的情况下运行命令。
我无法弄清楚为什么使用NPM脚本运行完全相同的命令导致问题?