Resolved! | ReferenceError: primordials is not defined

While working with npm commands, we generally face many heads shaking problems. many of them are resolved in seconds but some can ruin your days to resolve.

One of the similar issues we’re going to discuss in this post. I faced this NPM issue while working on an Angular project. I will share how and when this issue appeared and how to resolve this in seconds.

The issue I faced was:

} = primordials;

ReferenceError: primordials is not defined


What’s this issue?

In my case, this issue appeared in an Angular JS project while running the $ npm install command. This comes out to be the incompatibility between the version of Gulp and NodeJS installed on my system.

The Gulp version less than 4 is incompatible with NodeJs greater than 12.


How to resolve this issue?

There are two methods to resolve this issue which are explained below:


1# Method: Downgrade NodeJS version

You can downgrade the version of NodeJS to 10 which is compatible with Gulp less than 4. But vice-versa will not work. This means you can’t upgrade the Gulp to resolve this issue.


2# Method: Add Preinstall Script with Resolution

The second method is the preferred one. You can add the preinstall scripts. For that, you need to update your package.json file and make the following changes:


Step 1)

Open the package.json file, then add the following “preinstall” script under the scripts property.


Step 2)

Add “resolutions” property with “graceful-fs” version preferred is 4.x.x. You can read more about graceful-fs here.

So finally your package.json will look like this:

  "name": "my-app",
  "scripts": {
	  "preinstall": "npx npm-force-resolutions"
  "resolutions": {
    "graceful-fs": "^4.2.4"


After making the above changes in package.json file, make sure to execute $ npm install again to install the resolution package and run pre instal scripts.

Leave a Comment

Your email address will not be published. Required fields are marked *