Build Fails: `npm rebuild node-sass --force` - javascript

Using n to switch Node versions.
I've ran yarn, npm rebuild node-sass --force many many times. And still fails. Getting this error:
Node Sass could not find a binding for your current environment
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass --force` to build the binding for your current environment.
Anyone have any idea how to fix?
Also..
When running this command..
npm rebuild node-sass --force
I get..
npm WARN using --force I sure hope you know what you are doing.
Doens't seem like it is doing anything..

I did below to resolve the issue.
npm uninstall node-sass
npm i node-sass
npm rebuild node-sass

remove node-sass from your command and just run npm rebuild --force

If npm rebuild node-sass and npm rebuild node-sass --force doesn't work. Just uninstall node-sass and install again.

I have tried all options like:
npm rebuild --force
npm rebuild node-sass --force
npm rebuild node-sass &
also did try to install through Python &
updated VS Project links, but nothing worked..
EXCEPT running it manually:
node node_modules/node-sass/scripts/install.js

The main issue is that your node-sass and node-npm versions are incompatible.
Please see the chart on this site or on this.
So my suggestion is either adjust your node-npm version or adjust node-sass.
In my case I was using node-sassof version 4.9.4 with node version 8.12.0 and npm version 6.4.1, It was working fine without any issue, later on I got new system and I had installed the latest node(12.16.0) & npm(6.13.4) and issue started so I dug into this and found above links.
Hope this will help you.

I just ran the command npm install node-sass and my issue was resolved.

remove package-lock.json file
remove node_modules folder
then remove from package.json it devDependencies
"node-sass": "4...",
then
npm i node-sass -D
and
npm i

We are also facing the same issue many times, due to different versions of node and npm for numbers of web applications.
For that, we are just using the below command to take proper node-sass supported versions.
npm install node-sass or npm install node-sass -g
then try to rebuild the node-sass with,
npm rebuild node-sass or npm rebuild node-sass -f
After that all, if required then we can rebuild all packages and npm start or npm run watch and then the application is working properly.

try this, add/modify your package.json
"node-sass": "*",
and run
npm install

Uninstall and reinstall node-sass. Consider moving to dart sass because node-sass is now deprecated.

Switching Node version to 12.18.x worked for me.

I solved it with npm rebuild node-sass --force, in my case I had to do it as sudo

Related

Cannot install Vue Cli on Mac Catalina [duplicate]

While installing the dependencies of vue-cli, vue is not identified. Why?
rm -rf node_modules and npm install again
have a look here
Add sudo before yarn when installing
yarn global remove #vue/cli
sudo yarn global add #vue/cli
vue
I had the same issue for a while.
TL;DR
npm install #vue/cli-service --save-dev
As the documentation specify it is a development dependency https://cli.vuejs.org/guide/#cli-service
The CLI Service (#vue/cli-service) is a development dependency. It's an npm package installed locally into every project created by #vue/cli.
Origin
I had a fresh install of nodejs
And just did
>> sudo npm install -g #vue/cli#latest
>> vue --version
#vue/cli 4.5.8
The issue
The issue presented like this
>> npm run serve
yarn run v1.22.10
$ vue-cli-service build --mode development --watch
/bin/sh: 1: vue-cli-service: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The fixes:
npm install #vue/cli-service --save-dev
Which led me straight to another error message
>> npm run serve
yarn run v1.22.10
$ vue-cli-service build --mode development --watch
ERROR Error: Cannot find module 'vue-template-compiler/package.json'
Which I fixed the same way
npm i vue-template-compiler --save-dev
And now it is working fine.
Installing current version without permanently installing vue-cli.
npx #vue/cli create appname
It shows the vue executable is located at /home/alisha/.local/bin. So probably this location is not there in your $PATH.
You should be able to run the vue commands if you provide the full path, like:
~/.local/bin/vue create hello-world
You can also see if that directory is in your PATH by running some command like:
echo $PATH | grep '.local/bin/'
If it's there, you would see it, otherwise you can add it to your path by placing it in your ~/.profile.
Edit ~/.profile and add the following at the bottom of it.
PATH="$HOME/.local/bin:$PATH"
Hope it helps!!
I had the same issue while making a build for production.
You will require vue-cli to be installed. Use below command to install the latest version.
npm install -g #vue/cli#latest
Then
npm install
Might have to do with you having an old version on your computer:
Warning regarding Previous Versions
The package name changed from vue-cli to #vue/cli. If you have the previous vue-cli (1.x or 2.x) package installed globally, you need to uninstall it first with
npm uninstall vue-cli -g or yarn global remove vue-cli.
You can find it here: https://cli.vuejs.org/guide/installation.html
THIS FIXED THE ISSUE FOR ME:
After running
sudo npm install -g #vue/cli
I ran
sudo nano $HOME/.profile
and pasted the following line
export PATH=$PATH:/home/chike/.npm-global/bin
after writing the code, next thing I did was Ctrl + O, ENTER and Ctrl + X then wrote
vue init webpack myapp
When you install vue using cli that time you got the path of vue.Now you can copy the bin folder path.
In my example /home/sublime/.npm-packages/bin
Now you export the path below command
export PATH=$PATH:/home/sublime/.npm-packages/bin
I solved mine by running (add sudo if needed)
npm i -g vue-cli#2.9.6
npm i -g #vue/cli
Got similar issue when deploy vue project in jenkins.
Here is what I did:
Add node's bin/ dir, to jenkins user's .bashrc file.
e.g
# node
NODE_HOME=/home/dev/.nvm/versions/node/default
PATH=$NODE_HOME/bin:$PATH
Tips - about nvm & yarn
When you manage node version via nvm, make sure you already choose the node version in terminal. e.g:
nvm use stable
node -v
If you use nvm, and installed yarn via npm, then better install vue-cli via npm not yarn, otherwise the vue executable is not placed into node's bin/ dir, at least that's the case in my tests, and as a result will cause you fail to find the vue command.
Using Yarn on Ubuntu it is installed to ~/.npm-packages/bin/. You must add this directory to your PATH. For example run the following command, close your terminal and open a new one.
user#machine:~$ echo 'export PATH="$PATH:~/.npm-packages/bin/"' >> ~/.bashrc
Note: if the file ~/.bashrc does not exist then simply create it.
Following worked for me:
First remove all the existing ones:
yarn global remove #vue/cli
yarn global remove #vue/cli-service
sudo yarn global remove #vue/cli
sudo yarn global remove #vue/cli-service
Then add #vue/cli using sudo:
Note: use sudo if required
yarn global add #vue/cli
yarn global add #vue/cli-service
Then, the final thing to do is to RESTART the terminal.
vue --version
#vue/cli 4.5.9
If you already got a project, the only two things you need to do is:
Delete the directory node_modules (it is safe, since it is not under git and will regenerate in the next step)
In the command-line write yarn install (it will install everything you need)
If you start installing vue-cli manually in a existing project, it the package.json and package-lock.json will be updated. If you already did. Do a checkout from git, and follow my steps above
This may be a problem caused by version conflicts. "export PATH=$PATH:" This is really useful in some cases. But if you are also like me, after trying the direct “export path” method in the comment above, restarting the terminal still can not execute the situation, you can try this way.
Uninstall Vue
npm uninstall -g #vue/cli
Check the local-global npm package installation path, vue is installed in this directory, check if it has been removed.
npm root -g
Install vue (you can check with https://cli.vuejs.org/#getting-started to find the latest command)
npm install -g #vue/cli
Create a connection to the /usr/local/bin directory(You need to find the vue.js path after the local installation first, then replace this path with your latest local install path:/Users/xxxxx/.npm-global/lib/node_modules/#vue/cli/bin/vue.js)
ln -s /Users/xxxxx/.npm-global/lib/node_modules/#vue/cli/bin/vue.js /usr/local/bin/vue
View version number
vue -v
I was getting the same error because Node.js was not installed. My issue got resolved by installing Node.js using the following command:
sudo apt install nodejs-legacy
To see if you already have Node.js and npm installed and check the installed version, run the following commands:
node -v
npm -v
If both are installed then follow the steps here:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
I installed the package using yarn global add #vue/cli on my Ubuntu box and found the binary in /home/vonkad/.yarn/bin.
I had to modify my /home/vonkad/.bashrc and add the directory to the path export PATH=$PATH:/home/vonkad/.yarn/bin.
To fix this situation, I had to add the following line to my .zshrc (maybe in your case is .bashrc)
export PATH="$(yarn global bin):$PATH"
Effectively, the yarn global bin is a folder where vue (vue-cli 3) was placed.
What helped me
mac os catalina with zsh terminal
Uninstalled node and npm using https://www.positronx.io/how-to-uninstall-node-js-and-npm-from-macos/
Downloaded node/npm from https://nodejs.org/en/download/current/
sudo npm install -g #vue/cli
vue --version (#vue/cli 4.5.4)
I faced the same issue and now resolved. In my case I installed Node.js and NPM using the default Ubuntu repository by using this command sudo apt-get install nodejs npm
The problems seemed like those 2 packages are not well maintained so it caused some bugs.
So I purge those packages and reinstall it from nodesource which is officially recommended way to install (reference: Installation instruction from nodesource) using these commands.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Then reinstall #vue/cli again
sudo npm install -g #vue/cli
Now these issues have gone. Hope it helps some programmers.
You need to install vue via sudo like explained in the doc:
https://cli.vuejs.org/guide/installation.html
If you have WSL2 running and you use zsh like me, just add
yarn global add #vue/cli
# add this line to ~/.zshrc
export PATH="$HOME/.yarn/bin:$PATH"
$ vue --version
#vue/cli 4.x.xx
You can try the following code install see
npm install --global vue-cli
vue init webpack <YOUR-PROJECT-NAME-HERE>
cd <YOUR-PROJECT-NAME-HERE>
npm install
npm run dev

I've been trying to create a react app but I keep getting this error: "npm ERR! cb() never called!"

this is the problem
HP#DESKTOP-1HP83V8 MINGW64 ~/Desktop/Web-Development (master)
$ npx create-react-app my-app
Creating a new React app in C:\Users\HP\Desktop\Web-Development\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! https://npm.community
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HP\AppData\Roaming\npm-cache_logs\2020-11-20T11_50_51_060Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts >cra-template has failed.
I've encountered this multiple times.
First I would suggest that you run npm uninstall -g create-react-app since the global version isn't supported anymore.
Then try npx create-react-app my-app again.
If that does not work, try to run:
npm init
npm install create-react-app
npx create-react-app my-app
The steps above have solved the issue for me a couple of times
Disconnect and reconnect to your source of internet (WIFI).
After that, run npm cache verify
Next you will want to run: rerun npx create
Working Solution: thanks to idkwhatsgoingon's answer.
create-react-app does not work globally
npm uninstall -g create-react-app
npm install create-react-app
create-react-app app01
try this command first:
npm cache clean --force
and create your react app again.
I got the same error .Here these things i did to solve it
I ran npm cache clean --force
after again npx create-react-app project name
I tried all of these, it did not work. But I restarted the computer and it started working ! So after clearing the cache etc, might be be worth restarting the machine ( Windows 10 )
I got the same error when trying to install netlify-cli.
Here are two things I did to solve it:
I deleted some files to clear up disk space
Since my npm version is 6.0+, I ran "sudo npm cache verify"
Add the line
timeout=60000
to your .npmrc config file (create it at ~/.npmrc if it doesn't exist)
then run npx create-react-app project-name should be successful. At least it was in my case. (I had code ERR_SOCKET_TIMEOUT before)
Try installing yarn. I did this and immediately fixed my issues.
npm install --global yarn
first and foremost uninstall create-react-app by
npm uninstall -g create-react-app
then
npm cache clean -f
then
npx create-react-app app-name
this worked for me
I run npm cache verify
After this command, I run sudo apt install rerun
Then I run the command rerun npx create-react-app <app-name>
It worked like magic

npm ERR! Cannot find module './access-error.js'

Anything I try to do with NPM, I end up with npm ERR! Cannot find module './access-error.js'. Help!
I first noticed it when trying to install vue-chartjs. I ran npm install vue-chartjs chart.js --save like the docs said to do and got the error:
code/premium-poker-tools [master●] » npm install vue-chartjs chart.js --save
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './access-error.js'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/adamzerner/.npm/_logs/2019-03-12T23_56_46_114Z-debug.log
Then I tried installing chart.js and vue-chartjs individually, but it gives me the same error.
Then I googled the issue. I tried:
rm -rf node_modules
npm install
and it didn't work.
I tried reinstalling NPM and it didn't work. I tried removing NPM via sudo npm uninstall npm -g and then planning on reinstalling it after, and it didn't work. Everything I do gives me the npm ERR! Cannot find module './access-error.js' error.
This problem sounds very similar to one I had a few weeks ago.
What worked for me was removing Node.js from my Mac and reinstalling it, because installing Node.js installs npm as well.
Command used to remove Node.js: sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
Then just reinstall Node.js and everything should work again!
Hope this helps!
Ran into the same issue. Was using Node v8.11.4. Switched to Node v8.9.4 and it started working again...
Using NVM, I did the following:
nvm ls
nvm install <different version>
nvm alias default <different version>
Best guess is that it wasn't 8.11 specifically, but something with my particular installation was messed up and using a fresh install fixed it.
Not very satisfying. ¯\_(ツ)_/¯
I faced the same problem. Found that the node version is different.
Try the following:
1. nvm ls
2. nvm use <latest version available>
Now baam .. it works.

Angular CLI gives me "TypeError: callbacks[i] is not a function" when I "ng serve"

I literally just made a fresh installation of the Angular CLI in order to try it out and I don't have a clue on what's causing the following error on the command line:
PC:cobros Fran$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
95% emitting/Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:40
callbacks[i](err, result);
^
TypeError: callbacks[i] is not a function
at Storage.finished (/Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:40:15)
at /Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:77:9
at /Users/Fran/Documents/Workspace/Repos/cobros/node_modules/graceful-fs/polyfills.js:287:18
at FSReqWrap.oncomplete (fs.js:153:5)
This is the information I get returned when I try "ng -v" (In case it's useful at all):
Angular CLI: 1.6.8
Node: 8.9.0
OS: darwin x64
Angular: 5.2.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
#angular/cli: 1.6.8
#angular-devkit/build-optimizer: 0.0.42
#angular-devkit/core: 0.0.29
#angular-devkit/schematics: 0.0.52
#ngtools/json-schema: 1.1.0
#ngtools/webpack: 1.9.8
#schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0
What does the 'enhanced-resolve' module even do?
Did I install angular wrong? I followed the instructions from https://github.com/angular/angular-cli and made sure I fulfilled the prerequisites.
EDIT: The issue is now fixed, so there is no need to use this workaround anymore.
Solution (workaround) found here
Add "copy-webpack-plugin": "4.3.0" to your package.json
Thanks #neshkatrapati
I had same problem and this command did miracle for me
npm install copy-webpack-plugin#4.3.1
This issue should now be resolved with v4.4.1 released just now.
https://github.com/webpack-contrib/copy-webpack-plugin/releases/tag/v4.4.1
EDIT: The issue is now fixed, so there is no need to use this workaround anymore.
Happens after upgrading #angular/cli to 1.6.8.
Solution: Problem is with copy-webpack-plugin (https://github.com/webpack-contrib/copy-webpack-plugin/issues/217)
npm i copy-webpack-plugin#4.3.1 --save-dev helps
NOTE: Previous offered solution was to downgrade cli to 1.6.7, which does not help.
As stated here https://github.com/angular/angular-cli/issues/9550 it's a problem with copy-webpack-plugin.
It can be solved by doing npm install copy-webpack-plugin#4.3.0
Following github.com/angular/angular-cli/issues/9550 (thanks #oers for the link in the comments)
I just downgraded Anuglar CLI to version 1.6.7.
To do so, just type
npm uninstall -g #angular/cli
And once it finished install a previous version
npm install -g #angular/cli#1.6.7
NOTE: This will work but it is just a temporary solution, they probably -and hopefully- hot fix this.
EDIT: Actually I tried the wrong project which wasn't using CLI, tried again and it doesn't work, if you follow the github thread, it looks like a big thing, as it doesn't work with CLI 1.5.x nor 1.6.x (didn't tried with the others). It looks like the only thing we can do ATM is either debug through or sit and wait.
OOPS!
if npm install copy-webpack-plugin#4.3.1 doesn`t help try add in package.json:
"optionalDependencies": {
"copy-webpack-plugin": "4.3.1"
},
"resolutions": {
"copy-webpack-plugin": "4.3.1"
}
Edit
Just execute yarn upgrade.
There was a release of copy_webpack_plugin fixing the bug (4.4.1), so this should be preferred for resolving this issue. With npm, npm --depth 9999 update should do the trick to update all dependencies recursively.
Regarding the depth argument for npm update:
As of npm#2.6.1, the npm update will only inspect top-level packages. Prior versions of npm would also recursively inspect all dependencies. To get the old behavior, use npm --depth 9999 update
Original answer below:
Solution
rm -rf node_modules package-lock.json
npm i copy-webpack-plugin#4.3.1 -E -O
npm i
Explanation:
We remove node_modules and lockfile
We specify copy_webpack_plugin only as a peer dependency (option -O) and with an exact version (option -E)
We install node_modules
Try this command -> npm install copy-webpack-plugin#4.3.0 resolved my issue
run this command npm install copy-webpack-plugin#4.3.0
callbacks[i](err, result);
^
TypeError: callbacks[i] is not a function
solution:-
npm install copy-webpack-plugin#4.3.0
Try to uninstall and reinstall Angular CLI :
Global package:
npm uninstall -g #angular/cli
npm cache clean
if npm version is > 5 then usenpm cache verifyto avoid errors (or to avoid using --force)
npm install -g #angular/cli#latest
Local project package:
rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
npm install --save-dev #angular/cli#latest
npm install

Installing Angular-CLI on Windows 10

I had installation issues of angular-cli on Windows 10 system.
The errors were related to Python dependencies and node-gyp. Something as below :
>execSync#1.0.2 install C:\Users\UserName\AppData\Roaming\npm\node_modules\angular-cli\node_modules\execSync
node install.js
[execsync v1.0.2] Attempting to compile native extensions.
{ Error: spawn node-gyp ENOENT
at exports._errnoException (util.js:1007:11)
Update
this seems to be fixed in newer releases and this solution is no longer required.
mukesh51 eventually solved the problem.
the installation seems to work in these steps:
npm install -g node-gyp
npm install -g windows-build-tools
npm install -g #angular/cli
I took these steps from here.
Uninstall
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
Update Global package
npm uninstall -g #angular/cli
npm cache clean
npm install -g #angular/cli#latest
I too faced the same issue initially when I installed angular directly using bash. The installation was error completely. Then I attempted to install locally in my project (without removing the global one). That appeared to have solved the problem but got an error on creating a new app.
So i uninstalled everything :
npm uninstall -g #angular/cli
and the reinstalled Angular using Windows Power Shell(as Admin)
npm install -g #angular/cli
This solved the entire problem! Hope it helps!
Use windows power shell to install angular-cli. It will run without any issues.
Windows 10 Solution
Look back at the trace of installation steps ... you may see that it found the Angular binary in the following location:
C:\Program Files\Git\usr\local\node_modules\#angular\cli\bin
I added an ENVT variable using this path and ng worked fine after that
I tried using npm install -g #angular/cli
npm downloaded files successfully and copied files to AppData but not able to use ng -v
After that, I tried following:
npm cache clean --force
Removes npm cache forcefully if you get warning using npm cache clean.
Then try
npm install -g #angular/cli#latest
I have successfully installed by trying the above solution in Windows10.
Both the CLI and generated project have dependencies that require Node 8.9 or higher, together with NPM 5.5.1 or higher.
try update node.js and npm
npm uninstall -g #angular/cli
npm install -g #angular/cli
if doesn't work:
Close the terminal, open a new one or use CMD or Git for windows instead.

Categories

Resources