Related
I have installed Node.js modules by 'npm install', and then I tried to do gulp sass-watch in a 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
I have tried this before gulp sass-watch:
npm -g install gulp-cli
I hit the same error. I suspect you're using Node.js 12 and Gulp.js 3. That combination does not work: Gulp.js 3 is broken on Node.js 12 #2324
A previous workaround from Jan. does not work either: After update to Node.js 11.0.0 running Gulp.js exits with 'ReferenceError: internalBinding is not defined' #2246
Solution: Either upgrade to Gulp.js 4 or downgrade to an earlier version of Node.js.
We encountered the same issue when updating a legacy project depending on gulp#3.9.1 to Node.js 12+.
These fixes enable you to use Node.js 12+ with gulp#3.9.1 by overriding graceful-fs to version ^4.2.10.
If you are using pnpm
pnpm supports overriding some dependencies versions. To do it, you should add a pnpm section in your package.json file:
{
"pnpm": {
"overrides": {
"graceful-fs": "^4.2.10"
}
}
}
If you are using yarn v1
Yarn v1 supports resolving a package to a defined version.
You need to add a resolutions section to your package.json:
{
"resolutions": {
"graceful-fs": "^4.2.10"
}
}
Thanks #jazd for this way to solve the issue.
If you are using npm
Run this command to know which version of Node.js you are using:
node -v
It will return a version number <major>.<minor>.<patch> such as 18.11.0.
If your version is v16.14.0 or above, then you can override the version of graceful-fs by adding an overrides section in your package.json file:
{
"overrides": {
"graceful-fs": "^4.2.10"
}
}
Otherwise, you need to use npm-force-resolutions as a preinstall script to be able to override the version of graceful-fs by changing your package.json file like this:
{
"scripts": {
"preinstall": "npx npm-force-resolutions"
},
"resolutions": {
"graceful-fs": "^4.2.10"
}
}
npm-force-resolutions will alter the package-lock.json file to set graceful-fsto the wanted version before the install is done.
If you are using a custom .npmrc file in your project and it contains either a proxy or custom registry, you might need to change npx npm-force-resolutions to npx --userconfig .npmrc npm-force-resolutions because some versions of npx don't use the current folder .npmrc file by default.
Origin of the problem
This issue stems from the fact that gulp#3.9.1 depends on graceful-fs#^3.0.0 which monkeypatches Node.js fs module.
This used to work with Node.js until version 11.15 (which is a version from a development branch and shouldn't be used in production).
graceful-fs#^4.0.0 does not monkeypatch Node.js fs module anymore, which makes it compatible with Node.js > 11.15 (tested and working with versions 12, 14 and 16).
Note that this is not a perennial solution but it helps when you don't have the time to update to gulp#^4.0.0.
Fix it in one minute:
Just follow these steps. I'm on Windows 10 and it worked perfectly for me!
In the same directory where you have package.json create a npm-shrinkwrap.json file with the following contents:
{
"dependencies": {
"graceful-fs": {
"version": "4.2.2"
}
}
}
Run npm install, and don't worry, it will update npm-shrinkwrap.json with a bunch of content.
Run gulp to start the project.
Use the following commands and install Node.js v11.15.0:
npm install -g n
sudo n 11.15.0
will solve
ReferenceError: primordials is not defined in node
Referred from #Terje Norderhaug #Tom Corelis answers.
Use the following commands to install Node.js v11.15.0 and Gulp.js v3.9.1:
npm install -g n
sudo n 11.15.0
npm install gulp#^3.9.1
npm install
npm rebuild node-sass
It will solve this issue:
ReferenceError: primordials is not defined in node
For me, Diego Fortes' answer works with one small change.
Here is my workflow if this error appears:
npm install
npm install gulp
create file npm-shrinkwrap.json with
{
"dependencies": {
"graceful-fs": {
"version": "4.2.2"
}
}
}
npm install (again) (Not npm install gulp again! Very important - otherwise the error will be come back)
gulp (now working)
Using NVM to manage what Node.js version you're using, running the following commands worked for me:
cd /to/your/project/
nvm install lts/dubnium
nvm use lts/dubnium
yarn upgrade # or `npm install`
Simple and elegant solution
Just follow these steps. It worked perfectly with npm install running multiple times or installing any other modules or even publishing project to artifactory.
In the same directory where you have package.json create a npm-shrinkwrap.json file with the following contents:
{
"dependencies": {
"graceful-fs": {
"version": "4.2.2"
}
}
}
Run npm install, and don't worry, it'll update npm-shrinkwrap.json with a bunch of content. Let's get rid of this updates by updating package.json scripts options.
"scripts": {
"preshrinkwrap": "git checkout -- npm-shrinkwrap.json",
"postshrinkwrap": "git checkout -- npm-shrinkwrap.json"
}
Now you can run npm install and your npm-shrinkwrap.json will be intact and will work forever.
Gulp 3.9.1 doesn't work with Node v12.x.x, and if you upgrade to Gulp 4.0.2, you have to completely change gulpfile.js with the new syntax (series & parallels). So your best bet is to downgrade to Node.js v 11.x.x (the 11.15.0 version worked fine for me) by simply using the following code in a terminal:
nvm install 11.15.0
nvm use 11.15.0 # Just in case it didn't automatically select the 11.15.0 as the main node.
nvm uninstall 13.1.0
npm rebuild node-sass
TL:DR
Gulp 3.* doesn't work on Node.js 12.* or above. You have to downgrade Node.js, or upgrade Gulp.
If you are short on time, downgrade Node.js to v11.* or below; if you need newer features, and have time to possibly fix a load of broken dependencies, upgrade Gulp to 4.* or above!
As others have already mentioned, Gulp 3.* is not supported on Node.js 12 or above, so you will have to downgrade your Node version to 11.* or below, OR upgrade your Gulp to 4.0.
The best option depends ultimately on how much time you have, as upgrading Gulp brings benefits of cleaner gulpfiles and in-built control over having tasks run in series or parallel, but also relies on you rewriting your gulpfile to a new syntax, and might (read: probably will - see end of this comment) cause conflicts with some dependencies.
Downgrading Node.js
This is the easiest and quickest option. Especially if you use n or nvm, as these allow you to very quick install and switch between Node.js versions.
Installing Node.js version on N
n 10.16.0
Installing a Node.js version on NVM
nvm install 10.16.0
Once you have done this, you may need to rebuild your npm dependencies or alternatively remove both your node_modules folder and your package-lock.json file and reinstalling your dependencies. Though if you are merely reverting to a preexisting Node.js version, you should probably be fine.
Upgrading Gulp
As mentioned above, this is a more time-intensive task, but it might bring benefits in the long run. For example, Node.js 12 has now introduced native support for ES Modules (behind an experimental flag) and full support in Node.js 13.
You may need to upgrade Node.js to use that, forcing you to upgrade Gulp. Or you may simply want the benefits of using Gulp 4, as it offers better and more efficient control over writing tasks.
There are a number of articles on this already, so I won't elaborate any further on the specifics, but to reiterate - this is not a quick job. Depending on the size of your project, there may be some notable rewriting required, and you may have dependencies that break. If you are in short supply of time, you should opt for simply downgrading Node.js, at least temporarily.
But I already have Gulp 4, and it still doesn't work!
If, like me, you are already using Gulp 4+ (I was using Gulp 4.0.2, originally on Node.js 10) and have recently upgraded (I upgraded to Node.js 13.8.0) are you are still getting the issue, it may be because a dependency is relying on an older version of Gulp, and that is getting caught in the pipeline.
In my case, gulp-combine-mq was a dependency using Gulp 3.9.*. Disabling this task in my gulpfile allowed Gulp to run again.
If this happens, you have a few options. You can,
Go without the plugin if it's not absolutely necessary
Find an alternative,
Fix the plugin
Needless to say, if you have several plugins that rely on an older version of Gulp - especially if these plugins are vital for your application - this is where there can be a huge additional chunk of time spent in upgrading Gulp (hence the warnings above).
If this happens, it is best to just downgrade Node.js, at least until patches can be issued.
I had the same error. I finally fixed that when I updated all packages and then mentioned the same Node.js engine version and npm version in package.json as it is in my local working system.
"engines": {
"node": "10.15.3",
"npm": "6.9.0"
}
I was getting this error when deploying on Heroku.
For more, check out Heroku support.
Check Node.js version:
node --version
Check gulp version:
gulp -v
If Node.js >=12 and gulp <= 3, do one of the following:
Upgrade gulp
sudo npm install -g gulp
Downgrade node
sudo npm install -g n
sudo n 11.15.0
How to Upgrade (or Downgrade) Node.js Using npm
In case the problem is not from gulp then check the unzip npm module. It's been around six years since the last time it was updated. It doesn't work with Node.js > v11.
Try this:
npm install -g n
sudo n 11.15.0
The problem occurred for me in Visual Studio's Task Runner Explorer only and not when running from the command line or PowerShell.
I realised that VS was ignoring the Node version I had set with NVM.
This post gave the answer: Configure which NPM is used by Visual Studio's Task Runner Explorer? by setting the PATH variable as a higher priority than external tools in VS, it used the Node version set by NVM and not the version installed with VS.
This error is because of the new version of Node.js (12) and an old version of Gulp (less than 4).
Downgrading Node.js and other dependencies isn't recommended. I solved this by updating package.json file, fetching the latest version of all dependencies. For this, I use npm-check-updates. It is a module that updates the package.json with the latest version of all dependencies.
Reference: https://www.npmjs.com/package/npm-check-updates
npm i -g npm-check-updates
ncu -u
npm install
In most cases, we will have to update the gulpfile.js as well like the following:
Reference: Gulp 4: The new task execution system - gulp.parallel and gulp.series, Migration
Before:
gulp.task(
'sass', function () {
return gulp.src([sourcePath + '/sass/**/*.scss', "!" + sourcePath + "/sass/**/_*.scss"])
....
}
);
Other configuration...
gulp.task(
'watch', function () {
gulp.watch(sourcePath + '/sass/**/*.scss', ['sass']);
}
);
After:
gulp.task('sass', gulp.series(function(done) {
return gulp.src([sourcePath + '/sass/**/*.scss', "!" + sourcePath + "/sass/**/_*.scss"])
...
done();
}));
Other config...
gulp.task(
'watch', function () {
gulp.watch(sourcePath + '/sass/**/*.scss', gulp.series('sass'));
}
);
Downgrading to Node.js stable fixed this issue for me, as it occurred after I upgraded to Node.js 12:
sudo n 10.16.0
I faced the same issue. What I tried and what worked for me:
Check the version of Node.js and Gulp.js (a combination of Node.js v12 and Gulp.js less than v4 doesn't work)
I downgraded the NPM version by:
sudo NPM install -g n
sudo n 10.16.0
It worked fine. Then just follow the instructions of your console.
Upgrade to 4.0.1 and make sure to migrate https://fettblog.eu/gulp-4-parallel-and-series/#migration
I was getting this error on Windows 10. It turned out to be a corrupted roaming profile.
npm ERR! node v12.4.0
npm ERR! npm v3.3.12
npm ERR! primordials is not defined
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
Deleting the C:\Users\{user}\AppData\Roaming\npm folder fixed my issue.
If keeping Node.js v12 while using the latest gulp ^4.0, follow these steps:
Update the command-line interface (just for precaution) using:
npm i gulp-cli -g
Add/Update the gulp under dependencies section of your package.json file
"dependencies": {
"gulp": "^4.0.0"
}
Delete your package-lock.json file.
Delete your node_modules folder.
Finally, run npm i to upgrade and recreate a brand new node_modules folder and package-lock.json file with correct parameters for Gulp ^4.0:
npm i
Note Gulp.js 4.0 introduces the series() and parallel() methods to combine tasks instead of the array methods used in Gulp 3, and so you may or may not encounter an error in your old gulpfile.js script.
To learn more about applying these new features, this site have really done justice to it: How to Migrate to Gulp.js 4.0
I fixed this issue on Windows 10 by uninstalling Node.js from Add or Remove Programs → Node.js.
Then I installed version 11.15.0 from https://nodejs.org/download/release/v11.15.0/
Choose node-v11.15.0-x64.msi if you're running Windows 64-bit.
If you're trying to install semantic-ui and the following error occurs then try downloading the latest version of Node.js js(13.5.0) with the latest features, from Node.js.org.
Moreover, rather than trying the NPM install semantic, you should just add the link (which you can find from the cdnjs link) to the header of your index.html file.
Gulp is making issue with Node.js version 11 and above. Uninstall your current Node.js version and reinstall the v10.15.1 version. Here is the link for that version. This helps me and it will solve your problem too.
https://nodejs.org/download/release/v10.15.1/
Install gulp and add your Node.js version to the package.json file like so:
{
"dependencies": {
"node": "^10.16.3"
}
}
I have tried a lot of suggestions to fix this problem for an existing project on my Windows 10 machine and ended up following these steps to fix it;
Uninstall Node.js from "Add or remove programs". Fire up a new Command prompt and type gulp -v and then node -v to check that it has been uninstalled completely.
Download and install Node.js v10.16.0 - not the latest as latest node & gulp combination is causing the problem as far as I see. During installation I didn't change the installation path which I normally do(C:\Program Files\nodejs).
Open up a new Command prompt, go to your project's directory where you have got your gulpfile.js and start gulp as shown in the image.
Please note sometimes when I switch between git branches I might need to close my Visual Studio and run it as Admin again in order to see this solution working again.
As far as I see this problem started to happen after I installed the latest recommended version(12.18.4) of Node.js for a new project and I only realised this when some FE changes weren't reflected on the existing web project.
Update: Today I had the same problem while setting up one of my existing projects on my new PC and I did the same steps + went to the directory where I have the gulpfile and then run npm install.
It seems you've upgraded your nodejs's version to be +12 and still using gulp 3.9.1
You can use one of the below solutions
Upgrade you glup version to be +4
Or simply you use NVM Node version Manager
To run multiple nodejs versions on the same machine.
I had this very same error, but it was caused by a different issue.
OS: windows 10
nodejs version: 15.12.0
npm version: 7.6.3
The cause of the problem was graceful-fs package.
Whenever I tried to run npm, even running npm-v was firing "ReferenceError: primordials is not defined".
I tried running npm install graceful-fs#latest, but it still didn't work, even though the package was latest version.
So what helped me?
run npm ls graceful-fs
This way you'll find all packages on which graceful-fs is dependency and which version it has. In my case it was mostly version 3.0, even though I've installed version 4.2.6
So how to fix it?
Open npm-shrinkwrap.json (not sure about packages-lock.json) and change search for graceful-fs - you'll see that it has older versions on a few places. Replace it with ^4.2.6 (or newer).
Then npm audit fix --force which will forcefully install the newer version everywhere.
Hope this works for you, it took me a few hours to find out how to fix it.
Since my project was using gulp version 4, I had to do the following to solve this
Delete folder node_modules
open package.json and update version
Here is the detail of version I am using
Now run npm install and then run gulp default. The error should be gone and you may see:
Task never defined: default only.
Remove package-lock.json or yarn.lock file.
Then remove node_modules.
After that modify the package.json file-
"dependencies": {
"gulp": "^4.0.0"
}
Then run- npm install
It will be enough to solve this problem.
This is because the compatibility issue between node and gulp in your system. Downgrading the node or upgrading the gulp will fix this issue.
sudo npm i -g n
sudo n 11.15.0
Try removing the node_modules folder and package-lock.json file and installing again using npm i command if still not working.
I am running a node application on terminal. Have recently upgraded to node v8.5.0, but am getting this error:
Error: The module '/tidee/tidee-au/packages/tidee-au-server/node_modules/bcrypt/lib/binding/bcrypt_lib.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 51. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at Object.Module._extensions..node (module.js:653:18)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/tidee/tidee-au/packages/tidee-au-server/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (module.js:624:30)
at Module._extensions..js (module.js:635:10)
at Object.require.extensions.(anonymous function) [as .js] (/tidee/tidee-au/packages/tidee-au-server/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/tidee/tidee-au/packages/tidee-au-server/server/helpers/encryptPass.js:1:16)
Any idea how to solve this?
You need to remove the module folder (bcrypt) from the node_modules folder and reinstall it, use the following commands:
$ rm -rf node_modules/bcrypt
$ npm install
// or
$ yarn
I had the same problem and nothing mentioned here worked for me.
Here is what worked for me:
Require all dependencies you need in the main.js file that is run by electron. (this seemed to be the first important part for me)
Run npm i -D electron-rebuild to add the electron-rebuild package
Remove the node-modules folder, as well as the packages-lock.json file.
Run npm i to install all modules.
Run ./node_modules/.bin/electron-rebuild (.\node_modules\.bin\electron-rebuild.cmd for Windows) to rebuild everything
It is very important to run ./node_modules/.bin/electron-rebuild directly after npm i otherwise it did not work on my mac.
You have to rebuild the package and tell npm to update it's binary too. Try:
npm rebuild bcrypt --update-binary
#robertklep answered a relative question with this command, look.
Only rebuild haven't solved my problem, this works fine in my application.
Simply run:
npm uninstall bcrypt
Followed by:
npm install bcrypt (or npm install, if bcrypt is declared as dependency in your package.json file)
Be sure you only have one version of NodeJS installed. Try these two:
node --version
sudo node --version
I initially installed NodeJS from source, but it was the incorrect version and 'upgraded' to the newest version using nvm, which doesn't remove any previous versions, and only installs the desired version in the /root/.nvm/versions/... directory. So sudo node was still pointing to the previous version, whilst node was pointing to the newer version.
you can see this link
to check your node verison right. using
NODE_MODULE_VERSION 51 means that your node version is nodejs v7.x, requires NODE_MODULE_VERSION 57 means you need upgrade your node to v8.x,so you need to upgrade your node. and then you need run npm rebuild command to rebuild your project
Most likely you have this issue due to the package-lock.json. Somehow it seems to block you from recompiling or rebuilding your dependencies, even if you explicitly run npm rebuild. I ran all the following to fix it for me:
rm package-lock.json;
rm -rf node_modules;
npm install;
I deleted the node_modules folder and run npm install and my application started without any errors.
I got the same error but I was trying to run a node application using a Docker container.
I fixed it by adding a .dockerignore file to ignore the node_modules directory to make sure that when the docker image builds, it builds the native packages for the image I wanted (Alpine) instead of copying over the node_modules compiled for my host (Debian).
Turns out my problem was user-error: make sure the version of node you are using for running is the same that you are using when running an npm install or yarn.
I use NVM for versioning node and was running yarn via a terminal, but my IDE was set to use an older version of node when running and it was throwing the error above. Matching my IDE's version of node in the run config to node --version fixed the issue.
Here is what worked for me. I am using looped-back node module with Electron Js and faced this issue. After trying many things following worked for me.
In your package.json file in the scripts add following lines:
...
"scripts": {
"start": "electron .",
"rebuild": "electron-rebuild"
},
...
And then run following command npm run rebuild
I got this error when running my app with systemd:
ExecStart=/usr/local/bin/node /srv/myapp/server.js
But I was using a different version for npm install in the shell:
$ which node
/home/keith/.nvm/versions/node/v8.9.0/bin/node
If this is your setup, you can either hardcode the node version in the service file or follow a workaround like this one.
I had the same problem and none of these solutions worked and I don't know why, they worked for me in the past for similar problems.
Anyway to solve the problem I've just manually rebuild the package using node-pre-gyp
cd node_modules/bcrypt
node-pre-gyp rebuild
And everything worked as expected.
Hope this helps
you need just run this below commands:
$ rm -rf node_modules
$ rm -rf yarn.lock
$ yarn install
and finally
$ ./node_modules/.bin/electron-rebuild
don't forget to yarn add electron-rebuild if it doesn't exist in your dependencies.
For Electron modules, install electron-rebuild.
Format:
electron-rebuild -o <module_name> -v <electron version>
Example:
electron-rebuild -o myaddon -v 9.0.0-beta.6
Specify the same version that you have installed in the current directory
You might have this experience where a standard node-gyp build would report as 64, then a basic electron-rebuild would report 76, not until you add -v with exact version it bumps to actual version 80 (for 9.0.0-beta.6)
I had a similar problem with robotjs. There were some deprecated code that required node v11, but I had already compiled electron code on v12. So I got basically the same error.
Nothing here worked as I was basically trying to rebuild electron and my other dependencies into node v11 from v12.
Here is what I did (part of this is based on chitzui's answer, credit where credit is due):
Back up package.json
completely delete the node_modules folder
completely delete package_lock.json
delete package.json (will reinit later)
Close any open editors and other cmd windows that are in the project's directory.
run npm init to reinit package, then missing data with old backed up package.json
run npm i
fixed
After trying different things.
This worked.
Delete your node modules folder and run
npm i
I faced the same issue with grpc module and in my case, I was using electron and have set a wrong electron version in the env variable "export npm_config_target=1.2.3", setting it to the electron version I am using resolved the issue on my end. Hope this helps someone who set env variables as given here (https://electronjs.org/docs/tutorial/using-native-node-modules#the-npm-way)
You could remove bcrypt entirely and install bcryptjs. It is ~30% slower, but has no dependencies, so no pains installing it.
npm i -S bcryptjs && npm uninstall -S bcrypt
We've installed it successfully for our applications. We had issues with bcrypt not compiling on AWS instances for Node v8.x
Potentially, inconsistency of the node JS versions is what causes the problem. As stated in the documentation. Be sure to use one of the lts release. E.g. specify this in your Dockerfile:
# Pull lts from docker registry
FROM node:8.12.0
# ...
Check the Node version you're using, might be a mismatch between what it is expected.
I just got this error running kadence the installed "kadence" script checks for nodejs first and only runs node if there is no nodejs. I have the latest version of node linked into my ~/bin directory but nodejs runs an older version that I had forgotten to uninstall but never caused problems until just now.
So people with this problem might check if node and nodejs actually run the same version of node...
In my case, I was in my office proxy which was skipping some of the packages. When I came out of my office proxy and tried to do npm install it worked. Maybe this helps for someone.
But it took me several hours to identify that was the reason.
In my case I was running nodejs instead of node. Due to nodejs being installed by the package manager:
# which node
/home/user/.nvm/versions/node/v11.6.0/bin/node
# which nodejs
/usr/bin/nodejs
run npm config set python python2.7 and run npm install again the party is on.
I have hit this error twice in an electron app and it turned out the problem was that some modules need to be used from the main process rather than the render process. The error occurred using pdf2json and also node-canvas. Moving the code that required those modules from index.htm (the render process) to main.js (the main process) fixed the error and the app rebuilt and ran perfectly. This will not fix the problem in all cases but it is the first thing to check if you are writing an electron app and run into this error.
I came here because I was getting this error for the quokka.js ext in vscode.
My solution:
(on a mac via the terminal)
1- I went to ~/.quokka
2- I ran nano config.json
3- I copied the code from config.json into a separate file
4- I deleted the code in config.json
5- I stopped and restarted Quokka.
6- Once I confirmed that Quokka was working without errors, I deleted the config.json file code.
this is occoures because you currently change your node js version,
just run in terminal in your project
$ rm -rf node_modules/bcrypt
then reinstall
$ npm install
you can start it. ok
I just upgraded to node version 9.0.0 and am now getting this error in the command line when trying to use npm install
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'internal/util/types'
I'm using:
OSX 10.10.5
Node version 9.0.0
NPM version 5.5.1
Extra information: I am also trying to do this with a Laravel 5.5 project. This is how I update my version of node: How do I update Node.js?
run
rm -rf /usr/local/lib/node_modules/npm
and then re-install Node.js will work in most cases
Leaving this here for anyone using the n nodejs version manager:
$ n 6.12.0 # Go back to a stable release
$ npm install -g npm#latest # Update npm to latest
$ n lts # Get 8.9.1
$ npm install #Should work now.
The MODULE_NOT_FOUND error seems to happen when changing between node versions and some files are possibly still being cached. I am not sure exactly but the above sequence of commands work for me.
When I first got this, I solved just running "npm install" again to make sure everything was installed.
I got similar error also on Windows 8 after I have just upgraded node js. First: how I ran into the issue then the solution that worked for me.
How I ran to the issue:
When I did npm --version and node --version I discovered that I wass running npm v3.x and node 5.x. So I went to nodejs.org site from where I downloaded node-v8.11.3-x64.msi. After installing the msi package I confirmed that my nodejs version was now v8.11.3 via node --version command.
Then, when I ran "npm install http-server" (w/o the quotes) that's when I got the issue:
npm ERR!
node v8.11.3
npm ERR! npm v3.5.3
npm ERR! code MODULE_NOT_FOUND
My resolution:
I did some research including on the internet and found out that the npm version pointed to in my path was the one in my roaming profile C:\Users[myname.hostname]\AppData\Roaming\npm. In other words, the npm being used is not the one in the updated package I have just installed which is located in C:\Program Files\nodejs.
The resolution was to delete npm and npm-cache in the roaming folder. Note, I used cygwin as I was not able to delete these folders via Windows cmd prompt. With cygwin, I navigated to
cd "C:\Users[myname.hostname]\AppData\Roaming"
Then I removed the aforementioned folders like so
rm -rf npm-cache
rm -rf npm
After that, I opened a new Windows cmd prompt and was able to now successfully install http-server like so:
npm install http-server
Hope this works for you.
For me it was package installation issue, so I just write,
npm i or npm install in the root of the application.
to open the terminal in the root of the application, if you're using VS-code right click on the package.json and click on Open in integrated terminal.
I founded this problem too, so I found that I have imported wrong module instead of express module I had imported router module after I had replaced this two my code work as well
If all the above solutions doesn’t work check for any blank spaces in your folder/file where you copied the path
Make sure you are inside the project folder.
Rename the folder "node_modules" to any other name (for example: node_modules_old).
Run command: "npm i" (the command will build new the folder node_modules).
Try running your program again.
If the problem is resolved and your program is running correct, delete the old folder node_modules.
If you are using libraries make sure to install everything with npm or yarn before starting. And in cases of you files if you are going to use them make sure to do the export.module thing everytime.
If you are working with Local modules then don't have node_modules. All things go well in a easy way.
But if you want to work with both local and node_modules then use
.mjs (extension) - For modules
.cjs (extension) - For common scripts which you want to run with node
in which you can use require statements like
var http = require('http');
var fs = require('fs');
but if using .js extension then use
import http from "http"
import fs from "fs"
And also your package.json for type
Haa well, I have spent two days on this and have done everything I can to fix this issue even tried resetting the system but none of them reloved the issue.
And accidentally found out what was causing this issue, it is because of & in my parent folder name. File hierarchy R&D>remix>blog, When I was trying to run the blog server it was throwing module not found, require stack error.
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: []
Solution: I have changed the parent folder name to RnD and it fixed the issue. If the file name contains any special characters(even parent folders) try updating it. In my case, it is &
The MODULE_NOT_FOUND error happened to me and even running npm install the error persisted.
Try to do this
For me, what worked was deleting the node_modules folder
rm -r -f node_modules/
After that, run the command to install the package.json dependencies
npm install
What happened to me was that when I ran npm install for the first time I had a very low internet connection and therefore I believe that the packages from package.json were not downloaded correctly and due to that the MODULE_NOT_FOUND error occurred. The funny thing is that just running the npm install command has no effect because it understands that the package is already there but it isn't. Similar as a corrupted data. In my case the npm update was without effect too.
If when you are using React And getting this error message. You can use this ,
NPM
npm install #reduxjs/toolkit
Yarn
yarn add #reduxjs/toolkit
I am having issues building an app because node-sass keeps failing with the error.
ERROR in Missing binding /Users/warren/Sites/random-docs/my-cms/node_modules/node-sass/vendor/darwin-x64-11/binding.node
Node Sass could not find a binding for your current environment: OS X 64-bit with Node 0.10.x
I have tried running
npm rebuild node-sass
which says
Binary is fine; exiting.
When running node -v I get v6.2.2
Which is different to what the sass error says "Node 0.10.x". I can't figure out why it is getting the wrong version. I have also tried removing the node_modules folder and running npm update or npm install, both of which did not resolve the issue. Any ideas?
I had the same problem
There is an error in your gulpfile:
Error: Missing binding E:\allapp\badshaindiancuisine\node_module\node-sass\vendor\win32-x64-46\binding.node
Node Sass could not find a binding for your current environment:Windows 64-bit with Node.js 4.x
Found bindings for the following environment:
- OS X 64-bit with Node.js 4.x
How to solve the problem
By going into the project folder and then executing the command:
npm rebuild node-sass
For those that are using Visual Studio:
Currently working for VS 2015, 2017, 2019, 2022 (via below and/or replies from this post)
Task Runner Explorer can't load tasks
For VS 2015
Go to: Tools > Options > Projects and Solutions > External Web Tools
For VS 2017(.3), VS 2019, and VS 2022
Tools > Options > Projects and Solutions > Web Package Management > External Web Tools (per #nothrow)
In VS 2017, 2019, 2022, you also need to put $(PATH) above $(VSINSTALLERDIR)\Web\External
Reorder so that $(PATH) is above $(DevEnvDir)\Extensions\Microsoft\Web Tools\External
Deleting node_modules and running npm install and then npm rebuild node-sass did nothing.
**Just execute: ** npm rebuild node-sass --force
If the above for some reason didn't work out for you, try this:
Delete node-sass folder under node_modules
npm install
In my case it also couldn't find Python.
Following procedure solved the issue (Windows):
npm rebuild node-sass --force
-- cannot find python.exe, if you have Python installed, add it to your path:
set PYTHON=C:\Python27\Python.exe
-- else: download python "Windows x86-64-MSI" installer from https://www.python.org/downloads/release/python-2714/
-- install python
-- at installation start check: add env variable to path
-- after successfull installation:
npm rebuild node-sass --force
-- finished successfully
Worked for me:
Just delete the node-sass folder and run npm install.
I had the same problem in a Windows environment, receiving the following error:
Error: Missing binding C:\Development{ProjectName}\node_modules\node-sass\vendor\win32-ia32-47\binding.node
Node Sass could not find a binding for your current environment: Windows 32-bit with Node.js 5.x
Found bindings for the following environments:
- Windows 64-bit with Node.js 6.x
None of the npm commands listed in the other answers here (npm install, npm rebuild node-sass, etc.) worked.
Instead, I had to download the missing binding and place it in the appropriate destination folder.
The bindings can be found on git. Match the file with the folder name identified after /node_modules/node-sass/vendor/ in your error message ('darwin-x64-11' in your case, so you'd want the darwin-x64-11_binding.node file).
Create the missing folder in your project (/node_modules/node-sass/vendor/darwin-x64-11), copy the .node file to the new directory, and rename it to binding.node.
Node-sass release URL:
https://github.com/sass/node-sass/releases
I had a similar problem and the reason was that there were two versions of Node installed in my machine: one "global" and another one at the project level.
Sass will build correctly only if the Gulp build is running under Node.js 4.x version, so make sure you upgrade the version of Node you are using.
PS: If you completely remove the node_modules folder in your project and re-build from scratch, npm will download the correct dependencies for your current system & node version.
npm rebuild node-sass --force
Or, if you are using node-sass within a container:
docker exec <container-id> npm rebuild node-sass --force
This error occurs when node-sass does not have the correct binding for the current operating system.
If you use Docker, this error usually happens when you add node_modules directly to the container filesystem in your Dockerfile (or mount them using a Docker volume).
The container architecture is probably different than your current operating system. For example, I installed node-sass on macOS but my container runs Ubuntu.
If you force node-sass to rebuild from within the container, node-sass will download the correct bindings for the container operating system.
See my repro case to learn more.
in some cases you need to uninstall and install node-sass library. Try:
npm uninstall --save node-sass
and
npm install --save node-sass
look at this its work for me,
Stack link here
node-sass node module uses darwin binary file which is dependent on the version of node. This issue occurs when the binary file is not downloaded or wrong binary file is downloaded.
[![Node sass error][1]][1]
Reinstall node modules will download expected binary of node-sass:-
For Mac users:
rm -rf node_modules
npm cache clean --force
npm i
npm rebuild node-sass --force
For Windows users:
rmdir node_modules
npm cache clean --force
npm i
npm rebuild node-sass --force
but for some users, you need to check your node version's compatibility with node-sass version. Make it compatible using below table and run above commands again to fix this issue.
This is node compatibility table with node-sass
NodeJS | Supported node-sass version | Node Module
Node 17 7.0+ 102
Node 16 6.0+ 93
Node 15 5.0+ 88
Node 14 4.14+ 83
Node 13 4.13+, <5.0 79
Node 12 4.12+ 72
Node 11 4.10+, <5.0 67
Node 10 4.9+, <6.0 64
Node 8 4.5.3+, <5.0 57
Node <8 <5.0 <57
If issue is still not fixed, check node-sass supported environment's list:- https://github.com/sass/node-sass/releases/
* Docker related answer here *
Answer for if you are seeing this problem, or something similar, and are using Docker.
Cause: When copying over the current file structure to inside the Docker container, you may be copying over node modules from one OS system to another (e.g. a Mac to Linux container).
Solution:
Add a .dockerignore, and inside add:
node_modules
This will cause an npm install to install the bindings for the docker environment, rather than your local machine environment.
If your terminal/command prompt says:
Node Sass could not find a binding
for your current environment:
OS X 64-bit with Node 0.10.x
and you have tried the following commands such as:
npm cache clean --force
rm -rf node_modules
npm install
npm rebuild node-sass
& still NOTHING works..
Just run this in the terminal manually: node node_modules/node-sass/scripts/install.js
now run npm start or yarn start
Try to add suffix --force
npm rebuild node-sass --force
For my particular case none of the above answers worked. So what it worked:
rm -rf node_modules
rm -rf /tmp/*
rm -rf /root/.npm/node-sass
npm uninstall --save node-sass
npm cache clean --force
npm cache verify to check that nothing is left in the cache
npm install
Altough I haven't tried to reproduce the sequence it was a combination of the above that worked.
In addition you may also try:
npm install --save node-sass or npm install node-sass -g
npm rebuild node-sass
npm install bindings
I had the same problem
throw new Error(errors.missingBinary());
^
Error: Missing binding /path/to/project/node_modules/node-sass/vendor/linux-x64-47/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 5.x
Found bindings for the following environments:
- Linux 64-bit with Node 0.10.x
- Linux 64-bit with Node.js 5.x
That was because I did npm install using a different nodejs version,
try deleting node_modules folder installing and starting
cd your_project
rm -rf node_modules
npm install
npm start or gulp or whatever
If you are using nvm do
nvm use stable // or your favorite version
// remove node_module directory
npm install
npm start or gulp or whatever
I had the same problem with Node v7.4.0 Current (Latest Features).
Did some reading here and downgraded Node to v6.9.4 LTS and after running npm rebuild node-sass it downloaded the binary and everything started working.
Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-48_binding.node
Download complete .] - :
Binary saved to D:\xxx\xxx-xxx\node_modules\node-sass\vendor\win32-x64-48\binding.node
Caching binary to C:\Users\user\AppData\Roaming\npm-cache\node-sass\3.13.1\win32-x64-48_binding.node`
I'm a Windows 8 user, recently updated Node to v8.11.1 and npm to v6.0.0 and faced similar issue. Nothing worked - npm install -g node-sass#latest or deleting the node-sass directory from the project node_modules/ - none of 'em worked for me.
The Laravel Mix was throwing an error to my browser console saying a missing node: win32-x64-57. I don't know whether it's because a slower internet connection or something, the node was missing during the update.
Hence some of the answers directed me to look at the Node-Sass releases, and I found the solution.
Step 1: Check your node-sass version using the command: npm view node-sass version (the {your version} in step 4)
Step 2: Get to Node-Sass Releases
Step 3: Get your release and find the missing node in the assets listed under every release, and download the file
Step 4: Get to your PC's C:\Users\{User}\AppData\Roaming\npm-cache\node-sass\{your version}\ and put the downloaded .node file inside the version folder
And you are done.
In my case the node-sass version was 4.9.0 and the missing node was win32-x64-57_binding.node, so I downloaded the .node file from 4.9.0 release and followed step 4.
For Visual Studio 2015/2017, Right Click on your package.json and Click on Restore Packages.
This will make sure that the npm from the Visual Studio Tools External Tools is run and the binding will be rebuild based on that.
I had the same issue. I couldn't find any proper working solution in here, so I found mine:
Inspired by #Rob-Scott solution and other pointing that we could have 2 versions of Node.js installed, I went to C:\Program Files (x86)\nodejs and realized that I had a node.js version installed in addition to the VS default installation.
My solution was quite simple:
Go to Tools > Options > Projects & solutions > Web package management > External web tools
Click on add an entry (most left of the top-right block of buttons)
Enter C:\Program Files (x86)\nodejs, validate by pressing enter
Bring it at the top of the list
Enjoy
Probably Node.js is not set well in the PATH variable, but this is my working very quick solution, my 2 cents :)
This happens when in your workstation you run an update of Node.js and you are using node-sass globally.
So you should uninstall node-sass globally
npm uninstall -g node-sass
And then you have to install it globally, again
npm install -g node-sass
The post dependencies for node-sass is not getting installed without the package.json inside node-sass
Running it manually solved for me
node node_modules/node-sass/scripts/install.js
credit: link
Run the following commands, it works fine for me.
npm install node-sass -g
npm rebuild node-sass
nvm use 10.16.3
node node_modules/node-sass/scripts/install.js
ng serve --poll=2000
This worked for me:
yarn add --force node-sass#4.14.1 or yarn add --force node-sass
This usually happens because the environment has changed since running npm install.
Running npm rebuild node-sass builds the binding for the current environment.
Create a new directory in node_modules/node-sass/vendor/linux-x64-46/ .
the download fil from https://github.com/sass/node-sass/releases
(linux-x64-59_binding.node) based upon your version.
paste it in node_modules/node-sass/vendor/linux-x64-46/ rename it to binding.node
I had this issue when upgrading from VS 2017 Professional to Enterprise
Close VS
Delete node_modules
Open VS
Right click package.json and select 'restore packages'
Delete node_modules folder.
Install dependencies again. (npm i)
None of the install/rebuild solutions resolved the issue for me (using gulp).
Here is how I resolved it:
1) Download the missing binding file from the repository.
2) Rename the file binding.node.
3) Create node_modules/node-sass/vendor/darwin-x64-11 (path from error message) directory if it doesn't exist.
4) Add the binding file to node_modules/node-sass/vendor/darwin-x64-11
Just refresh your npm cache and:
npm cache clean --force
npm install
It always works for me in the same case.
UPD: Your problem may also be by reason of absence of a global sasslib.
npm install -g sass
Open Visual Studio 2017
Go to Tools -> Options…
Go to Projects and Solutions -> Web Package Management
Move $(PATH) to the top of that list and close that window.
Restart Visual Studio.
This worked in my case, because my node version is 11.x
Probably you have a build with different node version than the current one. Try running these commands and it should fix the issue.
npm cache clean --force &&
rm -rf node_modules &&
rm -rf package-lock.json &&
npm i
I have tried reinstalling and rebuilding npm, but the problem still persists.
Initially, the problem is with the module mongodb: I don't have that package, so I installed mongodb using this command npm install mongodb.
It shows me the following error:
dyld: Symbol not found: _node_module_register
Try deleting your node_modules folder and running npm install again.
rm -rf node_modules/
npm install
That should fix it.
Basically this error means - some binary packages was built under different node.js versions and not compatible to each other.
Via NVM make sure you are using proper version of node.js, run node -v;
After installing and switching to proper node.js version via nvm run npm update;
After all packages are updated (or downgraded) to compatible versions, run npm rebuild;
Note: npm rebuild might throw errors - just run npm rebuild again and again until it runs successfully.
Note: some commands may ask for root (sudo) permissions, - it depends from how you have installed packages, npm and node itself previously. nvm - never needs to be run as root (sudo).
If you just updated node and are running scripts via WebStorm, make sure you edit your Run/Debug Configurations and update the path to the Node Interpreter. I was using the node in
/usr/local/bin/node
, but after installing Node 4 using nvm, I need to use
/path/to/.nvm/v4.2.2/bin/node
This is what worked for me:
rm -rf node_modules/
sudo npm install
Make sure your nvm is pointing to the correct nodejs version. For me I used different (higher) while installing the npm modules. So just ran **nvm use** v14.7.0