javascript - 在 gulp 中运行 ng build 使用旧版本的 node.js

标签 javascript node.js gulp

我有一个 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 ngwhere gulp 的输出,您应该能够找到它并删除它。

关于javascript - 在 gulp 中运行 ng build 使用旧版本的 node.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58133716/

相关文章:

javascript - JS 类字段

javascript - 使用 Browserify 时如何公开 Google map 的回调函数?

javascript - 是否有 NPM 位置可以下载 Gulp 4 或 Gulp 4 的预发行版?

javascript - 在Google表格中按状态自动发送电子邮件

javascript - 立即函数与另一个函数调用 Javascript

node.js - 如何将流传输到 Node 中的文件描述符?

javascript - Node.js 应用给出 ERR_EMPTY_RESPONSE

node.js - NodeJS Socket.io 变量未定义

node.js - 语法错误 : Unexpected reserved word => prettier/third-party. js

javascript - 如何使用 javascript 或 JQuery 绕过打印对话框..?