Facing error while running ng serve command - node.js

I am trying to run ng serve command for my project , i tried npm i command for many times, but it showing same error continously.
Node version is : v16.13.2
Npm version is : 8.4.1
Image is of error

Your Issue
The error you facing with running the application is issue with the SCSS compilation. Certain packages are missing related scss
Try - npm rebuild node-sass --force
If still doesn't work out, freshly recreate the project and follow standard installation of libraries related to scss.
Helping Link:
Angular won't run my ng serve - Sass Loader error
Node Sass does not yet support your current environment: Linux 64-bit with false
Standard Angular Issue Resolution
Delete package-lock.json.
Clear cache - npm cache clean --force or npm cache clean -f
Delete node_modules folder
Reinstall dependencies - npm install
Run the application - ng serve

Please follow below steps to resolve this issue which worked in my case.
Delete node-sass folder (..\ AppData\Roaming\npm-cache\node-sass), node-modules folder and package-lock.json
Clear cache - npm cache clean --force
Reinstall node-sass globally - npm i node-sass#4.13.1 --unsafe-perm=true --allow-root
Reinstall project dependencies - npm install -no-package-lock
Start application - ng serve or npm start
This should update your node-sass global version. (please update version that you need to have as per your project)

Related

can not find module node-sass with angular 7

I cloned an old project of mine which I wish to revive.
The project is running with angluar 7 and ionic 4.
When running:
npm run build
I am encountering with the issue of Error: Cannot find module 'node-sass'
Now the environment is fresh new. with node 16.10.0 and npm 7 (those dependencies are because of the old project)
Trying to follow other questions that instruct me to install node-sass, just lead to incompatible versions.
Any suggestions?
If you are encountering an error when trying to run npm run build for an old project that was created with Angular 7 and Ionic 4, it's likely due to missing dependencies. To resolve the "Cannot find module 'node-sass'" error, try the following steps:
Uninstall the current version of node-sass by running npm uninstall node-sass
Reinstall the version of node-sass that was compatible with Angular 7 and Ionic 4 by running npm install node-sass#4.14.1
Clear the npm cache by running npm cache clean --force
Re-run npm run build and see if the issue has been resolved.
Note: It is always recommended to keep a record of the dependencies and their versions used in a project in a file such as package.json. This can help in situations where the dependencies have been updated and are causing compatibility issues.

npm WARN deprecated #npmcli/move-file#2.0.1: This functionality has been moved to #npmcli/fs

While installing Angular cli using the command:
npm install -g #angular/cli
I am getting this warning.
I am using node version 16.17.0 and npm version 8.19.2
I wanted to install angular cli. But ng command not working
Try the command 'ng v' and check if it asks any question about sharing data about this project with the Angular Team at Google google or any question at all about google say N as no. If it shows angular versions then it means angular/cli is installed
To solve this problem perform following steps:
npm uninstall -g #angular/cli
npm cache clean --force
npm cache verify
npm install -g #angular/cli
ng version
After this moment if you see that powershell is not allowing to execute the script
follow following steps from this site:
Chaman Gautam
and then run ng version(or any ng command you will be able to)
if you see angular
you are good to go !!!
I had the same problem recently. I tried uninstalling angular and reinstalling it but there were already 'ng' files at the location:
C:/Users/<your_user_name>/AppData/Roaming/npm
To resolve the issue, go to that npm folder and delete the following files:
ng
ng.cmd
ng.ps1
Once these files are removed, reinstall angular cli. Follow the guide here to clear the cache and do a clean install:
[https://www.javatpoint.com/uninstall-and-reinstall-angular-cli][1]
The ng command should work now. Check with the below command
ng --version
References:
[1]: https://www.javatpoint.com/uninstall-and-reinstall-angular-cli

Need to install 'webpack-dev-server'

I have cloned a repo from GitHub for a project. I've already installed node (-v 14.17.5) and npm (-v7.20.6), however when I run npm start I get the following code. I've tried reinstalling node and npm several times but I keep getting the same error:
$ npm start
> simplefolio#1.0.1 start
> webpack server --config webpack.dev.js --open
[webpack-cli] You need to install 'webpack-dev-server' for running 'webpack serve'.
Error: Cannot find module 'webpack-dev-server/bin/cli-flags'
Require stack:
- C:\Users\edwin\Desktop\git\simplefolio\node_modules\#webpack-cli\serve\lib\index.js
- C:\Users\edwin\Desktop\git\simplefolio\node_modules\webpack-cli\lib\webpack-cli.js
- C:\Users\edwin\Desktop\git\simplefolio\node_modules\webpack-cli\lib\bootstrap.js
- C:\Users\edwin\Desktop\git\simplefolio\node_modules\webpack-cli\bin\cli.js
- C:\Users\edwin\Desktop\git\simplefolio\node_modules\webpack\bin\webpack.js
Remove node_modules and package-lock.json, then npm i again
Remove node modules, then npm i again
In my case, I have node 16.13.0 and npm 7.20.1. Removing nodes_modules, package-lock.json and run npm cache clean --force alone didn't help. The key change for me is upgrading npm version to the latest (8.7.0), then combining with clean install.

Can't run Angular application with ng serve

enter image description here
Hi.
I can't build and run my Angular application. I tried to reinstall angular/cli, node.js and remove all node modules packages globally but it did not help.
try to do:
npm install
if the error persist you can do
npm install jquery --save
If the error still happens after npm install, try deleting the whole node_modules folder and run npm install again.

"libsass bindings not found. Try reinstalling node-sass"

So today I was trying to install MeepBot for StreamMe, and I ran into the error that says: "'libsass' bindings not found. Try reinstalling 'node-sass'." I reinstalled it like a million times. I have tried: "npm un/install --save-dev node-sass," "npm rebuild node-sass," etc. Can someone please give me an answer to my problem?
Picture: http://prntscr.com/axbxu8
P.S. keep in mind, I am using CentOS 6.
According to node-sass project's README.md only binaries for "popular platforms"(i.e. Windows/Mac) are included and you may need to build for other platforms like CentOS.
Here are roughly the steps (reading the readme would give you a better idea):
- cd to the node-sass directory within your project source.
- node scripts/install.js
- node scripts/build.js
Should see a message like Binary is fine; exiting.
Try to run npm rebuild node-sass again and it should work!
have you tried reinstalling everything? rm -rf node_modules; npm i. i've had to do that multiple times before.
otherwise, npm rebuild node-sass should work unless there are multiple versions of node-sass in your dependency tree - then maybe not. are you using npm v3+?
I would suggest try upgrading your gcc compiler as node-sass uses gcc to compile. And then try this -
npm rebuild node-sass
If that doesn't work then try runing this code (you must be using node version 4 or above).
npm install -g n
rm -R node_modules/
npm uninstall --save-dev node-sass
npm install --save-dev node-sass#2
npm install
npm -g install node-gyp#3
npm rebuild node-sass
If you are using multiple version of node then you will have to run npm rebuild node-sass every time you change node version.
You can also use gulp-sass npm install gulp-sass#2 if you want.
I was facing this issue. In my case the parent package.json was referring to new version of node-sass but the version of gulp-sass was referring to old node-sass. As soon as I updated gulp-sass to latest version, and ran 'npm rebuild node-sass', issue was gone.

Resources