我已经通过“npm install”安装了Node.js模块,然后尝试在命令提示符下执行gulp sass watch。之后,我得到了以下回应。

[18:18:32] Requiring external module babel-register
fs.js:27
const { Math, Object, Reflect } = primordials;
                                  ^

ReferenceError: primordials is not defined

我在大口大口看之前已经试过了:

npm -g install gulp-cli

当前回答

我在Windows 10上遇到了这个错误。结果是一个损坏的漫游配置文件。

npm ERR! node v12.4.0
npm ERR! npm  v3.3.12

npm ERR! primordials is not defined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:

删除C:\Users\{user}\AppData\Roaming\npm文件夹解决了我的问题。

其他回答

我在Windows 10上遇到了这个错误。结果是一个损坏的漫游配置文件。

npm ERR! node v12.4.0
npm ERR! npm  v3.3.12

npm ERR! primordials is not defined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:

删除C:\Users\{user}\AppData\Roaming\npm文件夹解决了我的问题。

一分钟内修复:

只需遵循以下步骤。我使用的是Windows 10,它非常适合我!

在package.json所在的目录中,创建一个npm-shrinkwrap.json文件,其中包含以下内容:{“相关性”:{“优雅的fs”:{“版本”:“4.2.2”}}}运行npm install,不用担心,它会用一堆内容更新npm-shrinkwrap.json。一口气开始这个项目。

安装gulp并将Node.js版本添加到package.json文件中,如下所示:

{
  "dependencies": {
    "node":  "^10.16.3"
  }
}

降级到Node.js稳定版为我解决了这个问题,因为它发生在我升级到Node.js12之后:

sudo n 10.16.0

看起来您已经将nodejs的版本升级到+12,并且仍然使用gulf 3.9.1

您可以使用以下解决方案之一

将您的glup版本升级到+4或者简单地使用NVM节点版本管理器在同一台机器上运行多个nodejs版本。