How to fix ReferenceError: primordials is not defi

2020-01-24 10:46发布

I have installed node modules by npm install, then I tried to do gulp sass-watch in command prompt. After that I got the below response.

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

ReferenceError: primordials is not defined

Have tried this before gulp sass-watch

npm -g install gulp-cli

25条回答
冷血范
2楼-- · 2020-01-24 10:58

I was also getting error on Node 12/13 with Gulp 3, moving to Node 11 worked

查看更多
【Aperson】
3楼-- · 2020-01-24 10:59

I fixed this issue on Windows 10 by uninstalling node from Add or remove programs -> Node.js

Then I installed version 11.15.0 from https://nodejs.org/download/release/v11.15.0/

Choose node-v11.15.0-x64.msi if your running windows 64bit.

查看更多
兄弟一词,经得起流年.
4楼-- · 2020-01-24 11:00

This might have come in late but for anyone still interested in keeping their Node v12 while using the latest gulp ^4.0, follow these steps:

Update the command-line interface (just for precaution) using:

npm i gulp-cli -g

Add/Update the gulp under dependencies section of your package.json

"dependencies": {
  "gulp": "^4.0.0"
}

Delete your package-lock.json file

Delete your node_modules folder

Finally, Run npm i to upgrade and recreate brand new node_modules folder and package-lock.json file with correct parameters for Gulp ^4.0

npm i

Note Gulp.js 4.0 introduces the series() and parallel() methods to combine tasks instead of the array methods used in Gulp 3, and so you may or may not encounter an error in your old gulpfile.js script.

To learn more about applying these new features, this site have really done justice to it: https://www.sitepoint.com/how-to-migrate-to-gulp-4/

(If it helps, please leave a thumps up)

查看更多
不美不萌又怎样
5楼-- · 2020-01-24 11:02

Are You Facing ReferenceError: primordials is not defined Error when trying to run gulp? Maybe you’re on gulp v3 and node v12, and that’s the source of the issue.

The thing is, gulp v3 doesn’t work (as of now) under node v12, because it depends on graceful-fs@^3.0.0 which patches Node’s fs module and that patch worked before node v12 just fine.

Solution for ReferenceError: primordials is not defined:

  1. upgrade gulp to v4 . This Solution Will Solve Your Error.

  2. To downgrade Node to v11 To Solve This Error.

  3. To pin graceful-fs to version 4.2.2 that’s known to work under Node v12 – That Option Explained Below This Option Is Worked for me So I recommend you this Option.

Here Is Example Of Option 3

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2020-01-24 11:05

I faced the same issue. What i tried and worked for me:- 1). Check the version of NODE and GULP (combination of node v12 and gulp less than v4 doesn't work) 2). I downgrade npm version by : #sudo npm install -g n #sudo n 10.16.0 It worked fine, then just follow instruction of your consol

查看更多
乱世女痞
7楼-- · 2020-01-24 11:06

had same error and finally fix that when updated all packages and then mentioned the same node engine version and npm version in package.json as it is in my local working system.

 "engines": {
    "node": "10.15.3",
    "npm": "6.9.0"
 }

i was getting this error when deploying on heroku.

for more checkout heroku support

查看更多
登录 后发表回答