How to fix “ReferenceError: primordials is not defined” error.

Completed

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:

1. First of All Find Your package.json and in the same directory create an npm-shrinkwrap.json file with the following contents

{
  "dependencies": {
    "graceful-fs": {
        "version": "4.2.2"
     }
  }
}


2. Now, Just Run npm install. it will update npm-shrinkwrap.json with a bunch of content.

It will solve Your Error.

Also Look Our Forum Question Answer For ReferenceError: primordials is not defined

2
4 comments

Thank you so much, i got really lost in finding a solution to this issue!

0

Worked for me.  A little more detail for those who might need it.  In my case, I had that conflict when running foundation-cli (foundation new --framework emails) on a windows 10 box.  I applied the above to c:\users\[name]\AppData\Roamding\npm\node_modules\foundation-cli and ran "npm i" from that folder.

 

0

Thanks mate! It did it for me.

0

Did not work for me - my problems started with gulp 4.0.2, so option 1 does not apply.

npm-shrinkwrap broke several low-level peer dependencies since the real culprit seems to be a  mish-mash of gulp plugins to support rollup. In particular, gulp-best-rollup requires rollup 1.4.1, so npm-shrinkwrap blows up with an error: unable to resolve dependency tree. --force just makes it worse. I've been waiting for an excuse to spend a week learning webpack - I guess this is it. 

0

Please sign in to leave a comment.