Referenceerror: primordials is not defined

If you have come across this Referenceerror: primordials is not defined error while working with Node.js or any associated frameworks, you have come to the right place.

In this guide, we will extensively explore the reasons behind this error and offer practical solutions to assist you in overcoming it.

Our goal is to equip you with the necessary knowledge and step-by-step instructions to effectively resolve this error.

What is primordials?

The “primordials” object was introduced in older versions of Node.js and was used internally by some packages.

However, in newer versions of Node.js (12.x and above), the “primordials” object was removed from the public API.

Consequently, if you encounter primordials in error, it usually indicates that you are using an outdated package or library that is not compatible with the version of Node.js you are running.

Now, let’s explore why and how this error occurs.

What is Referenceerror: primordials is not defined?

The “ReferenceError: Primordials is not defined” is an error which occurs when using older versions of Node.js or when there is a compatibility issue with certain packages or dependencies.

The error message indicates that the term “Primordials” is not recognized or defined within the context of your code.

Specifically, when you are using Gulp.js version 3 with Node.js version 12 or greater than that.

Causes of Referenceerror

So here are the factors why “ReferenceError: primordials is not defined” occurs:

  • The error often occurs when using an outdated version of Node.js that does not include the primordials module or where the module is incompatible with the code being executed.

  • If you’re working on a project that relies on third-party packages or libraries, the error can arise due to a version mismatch between these dependencies and the Node.js version you’re using.

  • Some build tools or task runners may not be compatible with the older version of Node.js you’re using, leading to the error.

Solutions to fix Referenceerror: primordials is not defined

Having discussed the potential reasons behind the “ReferenceError: Primordials is not defined” error, let’s proceed to the solutions.

Follow the provided solutions below to resolve this error and ensure seamless execution of your Node.js applications.

Updating Node.js

To begin, it is recommended to update your Node.js version to the latest stable release.

This ensures compatibility with newer packages and frameworks, reducing the chances of encountering the “ReferenceError: Primordials is not defined” error.

You can download the latest version from the official Node.js website (

Clear package cache

Clear the npm package cache by running the following command:

npm cache clean --force

This will remove any cached packages that might be causing conflicts.

Downgrade Node.js to version 11.x

An alternative approach to address the error is to downgrade your Node.js version to 11.

Using Node.js version 11 alongside gulp version 3 is compatible and won’t cause any problems.

Nevertheless, it is important to acknowledge that version 11 is significantly outdated, so downgrading is not advisable.

Upgrade Gulp to version 4

Another approach to resolve the error is to update your gulp version to either version 4 or the most recent one available.

# with NPM
npm install gulp@latest

However, if you are using YARN use this command:

# with YARN
yarn upgrade gulp@latest

Note. Gulp version 4 is independent of graceful-fs module version 3.0.0, allowing it to be compatible with Node.js version 12 and newer.

Reinstalling Dependencies

If the previous solutions haven’t resolved the error, it may be necessary to reinstall your project’s dependencies

Follow these steps:

  1. Delete the node_modules directory in your project.
  2. Open your terminal and navigate to your project’s directory.
  3. Run either npm install or yarn install, depending on your package manager, to reinstall the dependencies.

Example program

Suppose you have a JavaScript file named app.js, and upon running it, you come across the “ReferenceError: primordials is not defined” error.

To fix this error, you can refer to the aforementioned solutions.

Here is an example program:

// app.js
const fs = require('fs');

fs.readFile('file.txt', 'utf8', (err, data) => {
  if (err) {
    throw err;

Anyway, here are other fixed errors you can refer to when you might encounter them.


In conclusion, this guide has provided solutions to address the “ReferenceError: Primordials is not defined” error.

It is crucial to keep your dependencies updated and maintain an updated development environment to prevent similar issues in the future.

We hope this guide has assisted you in resolving the error effectively.

Until next time! 😊

Leave a Comment