dyld: lazy symbol binding failed: Symbol not found: _node_module_register - node.js

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

Related

Cannot find module 'fs/promises' Electron JS

Good morning,
I have created a program in Vue JS, this connects with an API that I have created in a main.js file to execute system commands.
The problem I have is that when compiling for production with electron I get the following error:
I use the command npm run electron: build
When I use npm run electron:serve work without problems
Anyone have any idea why is the error and how to fix it?
Thanks
I experienced this issue a few days ago as well. I realized that trying to fix another issue, I deleted the node_modules folder and the package-lock.json file, then run the npm install command. This made the build to fail with 'fs/promises'. There are 2 solutions to this issue:
Download the latest stable Node version. This should have the 'fs/promises' module and will fix the issue.
Delete the node_modules folder and bring back the old package-lock.json file to ensure that the package versions remain the same. Then run the npm install command and the issue should be fixed.
downgrade electron
"electron-builder": "^22.10.5",
or upgrade nodejs to 14+ v
downgrade to "electron-builder": "~22.10.5" is working for me
In that case I fixed the problem in that way:
const fs = require('fs').promises;
Instead of:
const fs = require('fs/promises');
In my case I was using nvm to manage multiple node versions.
During the npm package installation, and throughout development, I used Node v14 but for some reason, my terminal was pointing to Node v12 when I tried bundling my program afterwards.
Switching it back to Node v14 using nvm use 14 solved my issue.
So make sure you're using the correct node version.
Upgrade to electron-updater#5.0.0. It has patch changes replacing fs/promises with fs-extra to support legacy versions of electron.
got the same error "Cannot find module 'fs/promises'" while I don't use electron.
so the problem is not only related to electron
solved the problem just by upgrading nodejs from v13.9.0 to v14.19.3
If this happens to you (and I'm not using Electron either), and you have to stay on Node 12 like me (because the code you are maintaining is ancient), pray that you can get to one of the npm-shrinkwrap.json files you used that worked, then go through package.json, force every version to what was in the shrinkwrap file, rm -rf node_modules, and npm install.
I experienced this issue a few days ago. I realized that trying to fix another issue, I deleted the node_modules folder and the package-lock.json file, then run the
npm install
This made the build to fail with 'fs/promises'.
Delete the node_modules folder and bring back the old package-lock.json file to ensure that the package versions remain the same
then run the npm command with force
npm install --force
it work for me..
I had the same problem, after upgrading the electron-builder from v. 21.4.0 to 23.0.2, updated with the command:
 
sudo npm install -g electron-builder#23.0.2
I solved updating npm, and then node.js.
Update npm:
sudo npm install -g npm#latest
 
Install nodejs from https://nodejs.org
Now it works with :
 
Electron-builder: 23.0.2 (command electron-builder --version)
Npm: 8.7.0 (command npm --version)
Nodejs: v16.15.0 (command node --version)

npm ERR! cb.apply is not a function

I am getting this error
npm ERR! cb.apply is not a function
in Linux while doing npm install although my npm version is 6.9.0. My node version is v12.18.3. How to resolve this issue?
Would be helpful if you shared if it's Windows or Linux, but the error seems to occur on Windows. Possible solution:
1. Go to C:\Users(your username)\AppData\Roaming
2. Delete the npm folder (possibly back it up) and if there is one npm cache folder.
3. Run `npm cache clear --force` (--force is now required to clean cache)
After that, npm install should work fine.
Mac/Macbook users
Since this question is fairly active and a top google result for this issue (I know the OP is using Linux), here is how to fix it on a Mac.
On a Mac you do not have the AppData\Roaming folder, so simply run npm root -g and then navigate to the hidden directory and delete the node_modules there. If using nvm you'll need to rerun nvm use x.x.x (where x.x.x is your version).
Solution for Windows:
In my case I didn't want to delete all the npm directory inside C:/users/me/AppData/Roaming/ because I had many global modules that already existed and installed.
What worked was inspired by #user14360499's answer:
go inside C:\Users\me\AppData\Roaming\npm\node_modules
delete the npm dir
npm install my project, and keep working as usually
Solution for ubuntu 18.04:
sudo apt-get remove nodejs
sudo apt-get remove npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/bin/npm
sudo apt-get install nodejs
sudo apt-get install npm
Then try node and npm version:
node -v
npm -v
If it says there is no such node/npm after you already install, then:
sudo ln -s /usr/bin/node /usr/local/bin/node
sudo ln -s /usr/bin/npm /usr/local/bin/npm
Try this if the command works:
npm -v
node -v
In case when you want to update npm/node stable version:
sudo npm install n -g
sudo n stable
I had the same issue with Nodist. After changing my Node version, my npm version was actually incompatible with it. So if you're using Nodist, make sure to run nodist npm {scope} match after switching Node versions, where scope is either global, local or env.
For me, on Centos 7, it was about removing graceful-ts used locally by npx. First, I've had to open log file which was mentioned in the error message:
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-04-04T07_45_27_182Z-debug.log
In that log file there was this path:
verbose stack at /usr/local/lib/node_modules/npx/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
So I removed whole graceful-fs directory and ran npx again. Everything worked.
rm -fR /usr/local/lib/node_modules/npx/node_modules/npm/node_modules/graceful-fs
Had the same error (macOS Big Sur) when i tried to use npx.
How i fixed it (using nvm)
when i run:
nvm ls
nvm ls output
Fix:
nvm alias default node
nvm install 'lts/*'
nvm install output
Ciao, this problem could be connected to graceful-fs package. You could try to reinstall it:
npm install graceful-fs --save-dev
In my case it was indeed the graceful-fs package. Running
npm i -g --force graceful-fs
fixed the issue. I also ran nodist npm {scope} match before but I'm unsure if it was neccessary.
Solution for Ubuntu 18.04=>
Visit 'usr/lib/node_modules'.
Delete 'n', 'npm','npm-clean','npm-install-peers'. That means delete all the node & npm related folders.
Install the npm again.
I have tried a lot of solutions from different posts and google pages and nothing worked for me.
I ended up cleaning all traces of node, nodejs, and npm. May need some manual force remove after the purge call. And then installed using nvm.
https://linuxize.com/post/how-to-install-node-js-on-ubuntu-20-04/#installing-nodejs-and-npm-using-nvm
And it resolved the issue for me. It got the nodejs v 15.4.0 and the compatible version of npm 7.0.15 ( before using apt-get it was installing npm 6.9.0)
On macOS BigSur, I had this problem when executing:
npx install-peerdeps --dev eslint-config-airbnb
To fix, I ran
brew update
after which I was prompted to run
brew upgrade
Running the two commands fixed the issue.
I had this problem while trying to run npx.
I found that nvm had been removed from the PATH.
I added it back to my .zshrc file and it worked.
In my case (Mac) it was because I had npx installed alongside n (alternative to nvm).
$ which npx
/usr/local/bin/npx
I removed this exectutable and now:
$ which npx
/Users/MY_USER/n/bin/npx
and it works now.
I was getting this error when running npx sb init. For some reason, the command worked localy but not in CI. I tried most of the solutions from here. But only the following worked.
I replaced npx sb init with yarn global add #storybook/cli && yarn exec sb init as suggested here: https://github.com/yarnpkg/yarn/issues/3937#issuecomment-751289438
(NVM, Node.js 14, Yarn 1)
if you are also getting this error:
1 warn npm npm does not support Node.js v16.2.0
that means that your npm version is not correct.
reinstall npm, try again.
It works for me.
Feb 2021 fix:
npm install
And then commit the changes to package-lock.json. That should update all your dependencies, thus fixing this issue.
More info: https://help.heroku.com/ZV7S7D6T/why-is-my-node-build-is-suddenly-displaying-npm-err-cb-apply-is-not-a-function (this happened to me on heroku)
For linux users:
uninstall NPM, to do it go to /usr/local/lib/node_modules and do:
sudo rm -r n npm npx
Once uninstalled, re-instal it:
npm install
Even after doing this, in a specific project when trying to install a specific npm package, you may get the following error:
bash: /usr/local/bin/npm: No such file or directory
If so, in the terminal just run:
hash -r
Now you can retry installation of your wanted npm package.
For me , the solution was to delete the node modules and bower components folder of the project.
for the mac OS remove the node version and reinstalling was work for me. I used n npm version manager.
On windows, using nvm, i just installed a newer nodejs version (before 14.17.0, now 14.18.2)
So many solutions just made me even more puzzled. I downloaded and installed the newest LTS NodeJS and it worked just fine.
https://nodejs.org/en/
I'm on a Mac, and had exactly the same issue. Deleting the node modules seemed a little overkill for me, so I ran npm update and it solved the issue! Please note I did not yet have any package.json or any modules on the repo I was working in.
Windows 10:
When calling npx create-react-app my-app, i got following error:
npm ERR! cb.apply is not a function
To fix it, i did the following:
Go to the folder you want to create the app in.
npm install create-react-app --save-dev
npx create-react-app my-app
The problem has occured when the node and npm packages are not latest.
For me the problem is resolved when I completely removed npm and node, and made a clean installation.
I am using ubuntu 22 lts
to remove node and npm completely I have followed this answer
Had this issue when creating a new react app using create-react-app.
I was using nvm, so I just updated it to the latest LTS version:
nvm install --lts
then switched to the newly installed lts version:
nvm use --lts
closed and reopened the terminal, reran create-react-app and the error was fixed!
Solution for ubuntu =>
Completely remove nodejs and npm from your system.
sudo apt-get remove nodejs
sudo apt-get remove npm
Install node from this reference (https://computingforgeeks.com/install-node-js-14-on-ubuntu-debian-linux/) - This will inturn install latest npm .
Had the same error was simply in the wrong folder -.- (not a typescript project)

Node MODULE_NOT_FOUND

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

Node Sass couldn't find a binding for your current environment

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

Node Version Manager (NVM) npm installing modules to common folder

I've installed NVM for node.js using the instructions from this post:
http://www.backdrifter.com/2011/02/18/using-nvm-and-npm-to-manage-node-js/
When I switch between node versions and then use npm to install a module, all the modules are placed in the same 'node_modules' folder (~/node_modules/) instead of in the 'node_modules' directory specific to that version of node?
Any idea on how to remedy this?
Based on the comments from https://github.com/creationix/nvm/pull/97:
When installing packages with npm using the global switch -g the
package ends up in the proper directory (i.e.
.nvm/$VERSION/lib/node_modules), however node is unable to require it
since it somehow isn't searching on it's prefix.
So using npm install -g xxxxx will put the modules in the correct location for NVM but if you try to require one of them node can't find the module. I am still playing around with this and will update if I find a solution.
Update
Where does NPM put node_modules? (see https://docs.npmjs.com/files/folders)
Local install (default): puts stuff in ./node_modules of the current package root.
Global install (with -g): puts stuff in /usr/local or wherever node is installed.
Install it locally if you're going to require() it.
Install it globally if you're going to run it on the command line.
If you need both, then install it in both places, or use npm link.
So what I did was run npm init (see http://npmjs.org/doc/init.html) in my projects root dir which generated package.json. Now when I run npm install xxxxx it creates a node_modules dir in my project folder (which I add to my .gitignore). This works for modules that I require in my code.
For commands such as CoffeeScript I install with npm install -g coffee-script which puts it in the correct directory (.nvm/$VERSION/lib/node_modules). While I can't require these modules (npm link should solve this problem) I can run the commands - i.e. coffee.
I just installed express globally (-g) and was having problem when require("express"). Just like Jesse Vogt said I just reinstalled express but this time without the -g just like this: "sudo npm install express" and now is working perfectly!
For latest nvm window version 1.1.7.
Package was installed and placed into the respective nodejs version.
nvm use 16.8.0
npm install truffle
nvm use 16.7.0
npm install mysql

Resources