我有一个 gulp 脚本,用于使用 ng build 构建 Angular 文件。如果我从命令提示符运行它,它会起作用,但当我从 gulp 运行它时,它会失败并出现错误:
You are running version v10.6.0 of Node.js, which is not supported by Angular CLI 8.0+.The official Node.js version that is supported is 10.9 or greater.Please visit https://nodejs.org/en/ to find instructions on how to update Node.js.Process terminated with code 0.C:***> cmd.exe /c gulp -b "C:***" --color --gulpfile "C:***\Gulpfile.js" default
我已经全局安装了 Node v10.16.3 版本,但由于某种原因它说我有 v10.6.0
。我也在使用 Gulp 4。
我的 gulp 文件如下所示:
var exec = require('child_process').exec;
gulp.task('buildNg', async function (cb) {
exec('ng build', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
})
gulp 使用自己的 Node.js 版本吗?我没有看到任何其他原因。
最佳答案
在此消息中:
You are running version v10.6.0 of Node.js, which is not supported by Angular CLI 8.0+.The official Node.js version that is supported is 10.9 or greater.Please visit https://nodejs.org/en/ to find instructions on how to update Node.js
“v10.6.0”部分是 process.version
的输出 ( Source )
所以你的驱动器上有一个旧的 Node.js 安装。如果您检查 PATH
环境变量以及 where node
where ng
和 where gulp
的输出,您应该能够找到它并删除它。
关于javascript - 在 gulp 中运行 ng build 使用旧版本的 node.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58133716/