close

[Solved] ReferenceError: primordials is not defined

Are You Facing the Following error ReferenceError: primordials is not defined in NodeJS? Then You are in right place. In this article, we will try to figure out how this error occurs and what are the possible fixes for this error. First of all, let’s explore how this error occurs.

What is ReferenceError: primordials is not defined error?

Trying to run gulp command but fails with the following error.

ReferenceError: primordials is not defined

How To Fix ReferenceError: primordials is not defined Error?

  1. How To Fix ReferenceError: primordials is not defined Error?

    To Fix ReferenceError: primordials is not defined Error First of all Create npm-shrinkwrap.json at the root of your project folder. and add the following dependencies. Just after this you need to run npm install to update our npm-shrinkwrap.json file: npm install Now, you can run gulp command and your error will be solved.

  2. ReferenceError: primordials is not defined

    This error usually occurs when you are using gulp version 3 and node version 12 Because gulp v3 is dependent on graceful-fs and it was run fine before node version 12 but for node version 12 and 12+ you will face the above error. To Fix ReferenceError: primordials is not defined Error You need to override graceful-fs will resolve this issue. First of all Open your package.json file and add this override: “overrides”: { “graceful-fs”: “^4.2.10” } And now you can run gulp command without any error. Thanks.

Solution 1:

This error usually occurs when you are using gulp version 3 and node version 12 Because gulp v3 is dependent on graceful-fs and it was run fine before node version 12 but for node version 12 and 12+ you will face the above error. To Fix ReferenceError: primordials is not defined Error You need to override graceful-fs will resolve this issue.

First of all Open your package.json file and add this override.

{
  "overrides": {
    "graceful-fs": "^4.2.10"
  }
}

OR If Your Package.json file has pnpm support then you can add overrides in pnpm section just like this.

{
  "pnpm": {
    "overrides": {
      "graceful-fs": "^4.2.10"
    }
  }
}

And now you can run gulp command without any error. Thanks.

Solution 2: For Yarn Users

If You are using yarn then Open your package.json file and add graceful-fs as resolution just like this.

{
  "resolutions": {
    "graceful-fs": "^4.2.10"
  }
}

And now, your error will be solved.

Solution 3: Create npm-shrinkwrap.json

To Fix ReferenceError: primordials is not defined Error First of all Create npm-shrinkwrap.json at the root of your project folder. and add the following dependencies Just like this.

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

Just after this you need to run npm install to update our npm-shrinkwrap.json file.

npm install

Now, you can run gulp command and your error will be solved.

Solution 4: Update npm

If nothing is working then you need to update your npm package By running this command.

npm install -g npm@latest

Hope now, your error will be solved.

Conclusion

It’s all About this error. I hope We Have solved Your error. Comment below Your thoughts and your queries. Also, Comment below on which solution worked for you.

Also, Read

Leave a Comment