DEV Community

Brittany
Brittany

Posted on

ReferenceError: primordials is not defined

I've started to work on a project that I haven't really touched since 2017. As you can imagine, I'm getting tons of warnings due to all of my node packages being outdated.

When trying to run npm install or npm update this is one of the errors I was getting.

const { Math, Object } = primordials;
                         ^

ReferenceError: primordials is not defined

What does this even mean??

After some google searching, I saw that a lot of people were getting this error because they were running a version of Gulp that was incompatible with their current node version.

"Okay... cool. But I don't have Gulp installed! :< "
-me

I spent about 45mins-1hr trying to get rid of this error, but the thing that did it was removing sequelize-cli from my list of dependencies.

How did I realize that sequelize-cli was the source of the problem?

I deleted my node_modules folder and ran npm install because I had no idea what to do next and was trying anything I could think of.

Brittanys-MacBook-Pro-4:Gabble_Forum britthome$ npm install
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated natives@1.1.6: This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js

AND WHAM-O! Look at that. gulp-util you sneaky devil. I was really confused and searched my entire directory for that dependency but couldn't find it. That's when I got the idea that one of my listed dependencies must depend on Gulp.

I went to the npm website and searched for all of my dependencies one by one. On each package's page, you can see what packages it depends on. sequelize-cli was of course, my last listed package, but when I finally got to it, I saw that it does depend on Gulp.

So, what's next?

Because I created this project so long ago, I don't remember the necessity of each dependency, so I'm in the process of learning about each one and deciding if I really need it or not. Because I'm using sequelize, I imagine that I'll need some sort of CLI, but maybe there is a native CLI with the package or another package I can use? Maybe I won't even use sequelize. SO MANY DECISIONS!

Just wanted to share this little experience. Hopefully, it helps someone.

Top comments (6)

Collapse
 
krunal79flutter profile image
Krunal79-flutter

I am Having issue In Node Js
I have installed node modules by npm install, then I tried to do gulp sass-watch in command prompt. After that I got the below response.

[18:18:32] Requiring external module babel-register
fs.js:27
const { Math, Object, Reflect } = primordials;
^

ReferenceError: primordials is not defined
Have tried this before gulp sass-watch

npm -g install gulp-cli

Find Full Post icetutor.com/question/how-to-fix-r...

Collapse
 
afondevi profile image
Alexy

Hello !
So what is the solution to continue to use sequelize with this error ? :)

thanks !

Collapse
 
only8britt profile image
Brittany • Edited

Hi!!
Removing the depreciated package gulp-utils solved the issue for me.

A few questions:

  • When you run npm update or npm install do you see anything related to a deprecated package?
  • Are you using the sequelize-cli package?
  • What command are you running that result in ReferenceError: primordials is not defined

If you have a link to the repo I would love to look into it as well!

Collapse
 
afondevi profile image
Alexy

Ok I downgrade node to 11.15.0 and it works :) thanks

Collapse
 
khwilo profile image
Khwilo Kabaka

Switching to a different version worked for me. In my case, I switched to a node version which is less than 12.

Collapse
 
yafetissac profile image
yafetissac