How to fix ‘ReferenceError: primordials is not defined’ error NPM/Gulp/JS

in Code Write a comment

After switching to a new computer I installed the latest version of Node (v17). That was the cause of the “primordials is not defined” error.

Solution 1

A quick solution would be to downgrade the Node. I’ve found out that Node version 12 is compatible with Gulp version 3.*

How to check Node version in terminal

node --version

If you’re using Node version 14 or above, just downgrade it to version 12.

How to downgrade Node

brew unlink node

brew install [email protected]

brew link [email protected]

Solution 2

1. Delete node_modules folder

It’s important that you delete the node_modules folder before proceeding to the next step.

2. Create a new file called npm-shrinkwrap.json

Create an empty file in the same folder as your package.json file and call it npm-shrinkwrap.json.

3. Add the code below to npm-shrinkwrap.json

Copy and paste the code below to your newly created file.

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

4. Run npm install

Run npm install command. It will update npm-shrinkwrap.json with a lot of dependencies.

5. All done

Run gulp to start the project.

I hope you learned something new today. And if you did, please leave a comment and check other Vue.js tutorials.

Renat Galyamov

Want to share this with your friends?

A collection of UI components for
Bootstrap 4/5 and Vue.js

Get now

Write a Comment