can not find module node-sass with angular 7 - node.js

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.

Related

Facing error while running ng serve command

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)

Codelyzer requires Angular 9 instead of Angular 10

When I am running the command npm ls -json in my node js project I get the following error:
npm ERR! missing: #angular/core#9.0.0, required by codelyzer#6.0.2
npm ERR! missing: #angular/compiler#9.0.0, required by codelyzer#6.0.2
#angular/core and #angular/compiler are already installed in the dependencies of my project, but with version 10.2.4
The error only occures when I am running yarn install to install my packages. If I am using npm install everything works fine, but takes a while.
Is there any version of codelyzer that uses Angular 10 instead of Angular 9 or some other package that solves the same problem?
Environment:
OS: Windows
Package Manager: yarn
Angular version: 10
I found out, that Codelyzer is deprecated and I had to remove it and install "eslint" package instead. EsLint has included all features of codelyzer.
I found this Github conversastion and based on that
I just had to update the version for Angular 10. The Codelayzer version was #6.0.0

NPM 5 is not supported yet in React Native

While creating an app using React native, in cmd I'm facing the following error message:
ERROR: npm 5 is not supported yet.
npm WARN deprecated socks#1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
> #expo/ngrok#2.3.0 postinstall C:\Users\Rakesh\proj\node_modules\#expo\ngrok > node ./postinstall.js ngrok - binary unpacked.
npm notice created a lockfile as package-lock.json. You should commit this file. + react-native-scripts#1.11.1 added 459 packages in 316.717s.
It looks like you're using npm 5, which was recently released. Create React Native App doesn't work with npm 5 yet, unfortunately. We recommend using npm 4 or yarn until some bugs are resolved. You can follow the known issues with npm 5 at: https://github.com/npm/npm/issues/16991
You can downgrade your npm version by following
npm install npm#4.6.1 -g
and then try running app again.
Simply downgrade npm to 4.6.1 OR Install Yarn
npm install -g npm#4.6.1
OR
npm install -g yarn
Yarn is better but I will prefer to downgrade npm because for some reason I'm getting a yarn.lock file error.

Unable to start angular4 app using ng serve

I am executing following command in my angular 4 app,
ng serve
But i am getting the following error message,
This version of CLI is only compatible with angular version 2.3.1 or
better. Ple ase upgrade your angular version, e.g. by running:
npm install #angular/core#latest
my angular cli version is 1.6.8.
Even i executed the above mentioned command to update my angular cli, but still same error is getting reported.
Perform Following steps:
1. perform npm cache clean --force
2. Reinstall Angular CLI globally using following command:
npm install -g #angular/cli
3. Delete 'node modules folder' and perform npm install for your project and try running it with npm start/ng serve
From the github issue here: https://github.com/angular/angular-cli/issues/5558
The project needs a dev dependency for #angular/compiler-cli.
npm install --save-dev #angular/compiler-cli#<your angular version>
If that doesnt work you can try this:
npm install --save-dev #ngtools/webpack#1.2.13
One of the main contributors of angular-cli said that it is an issue with older webpack versions, reading the github thread should provide some more insight
To resolve the angular cli error, please try following steps :
npm uninstall —save #angular/cli
npm cache clean
npm install —save #angular/cli

"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