Consequences of disabling check_yarn_integrity? - node.js

I see a common message when trying to start the rails server:
rails s
=> Booting Puma
=> Rails 6.0.3.2 application starting in development
=> Run `rails server --help` for more startup options
error Couldn't find an integrity file
error Found 1 errors.
========================================
Your Yarn packages are out of date!
Please run `yarn install --check-files` to update.
========================================
To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).
yarn check v1.22.10
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.
I have tried for 2 days to fix this. Deleting node_modules and reinstalling, etc, but nothing I do has worked. So I am considering doing as the message suggests and disabling the yarn integrity check.
Question
What does this integrity check do, and should I be worried about disabling it?
Notes
Disabling this integrity check is suggested/recommended in a few places, including
https://github.com/rails/webpacker/issues/1374#issuecomment-495280789
Info
I reinstalled nvm, node and yarn just to eliminate possible causes of problems:
nvm -v
0.38.0
node -v
v16.0.0
npm -v
7.10.0
yarn -v
1.22.10

have you tried running the suggested command?
yarn install --check-files
you could also try reinstalling webpacker, which will create a new manifest file which will pass integrity checks:
rails webpacker:install

An update, the errors I was getting were very widespread, caused by a incompatibility with node 16 and a dependency (node-sass).
So rather than turn off the integrity check, I simply used nvm to downgrade to node 14

Related

use-yarn thinks I'm not using yarn

I have an app that uses yarn. I was having trouble with a yarn install... script. I tried a bunch of things, including using nvm to switch node versions. After that, I had a bunch of yarns installed and was still seeing the same unrelated issue (network issue pulling a dependency). So, I decided to switch back to the latest version of node and try something else. But, that introduced a new issue.
The yarn script stopped working completely. I'm using yarn install:deps and the result is to first run the preinstall script which does npx use-yarn and that errors and blocks continuation of the script. It says I'm not using yarn, though my command is yarn install:deps and which yarn shows that I am indeed running yarn.
How do you fix this?

getting error while installing the yarn in react js project

$ yarn install
yarn install v1.19.1
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies cau
sed by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/5] Validating package.json...
error app#0.3.0: The engine "node" is incompatible with this module. Expected version ">=10.17.0". Got "10.15.2"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
getting the errors while installing the yarn in react js project
error app#0.3.0: The engine "node" is incompatible with this module. Expected version ">=10.17.0". Got "10.15.2"
error Found incompatible module.
Remove package-lock.json and run yarn install --ignore-engines
When working on a team, sometimes another dev installs it. One good way to avoid this happening is using package-locks-checks, which I wrote.
If you run npx package-locks-checks it will check for this kind of inconsistencies and avoid you to have issues on production environment.

Angular CLI - ng serve - high cpu usage from node process

I am struggling with an issue where on running any angular app locally the node process linked to ng serve is using well over 100% of my CPU core's.
My current environment is:
Angular CLI: 7.3.10
Node: 11.15.0
OS: darwin x64 (Mac OS X Catalina 10.15.4)
Angular: 7.2.16
I have come across numerous posts and issues about this where the common solutions appear to be to install fsevents for Mac OS issues.
Things I have tried:
Installing XCode Command Line Tools for node-gyp to rebuild fsevents after its installed
Install the latest version of fsevents (2.1.3) as an older version is specified as an optional dependency with angular-cli (1.2.13)
Using a different node version, tried 12.13.0 and deleting node_modules and doing a clean install. Also tried latest fevents version again
Incase its relevant I use nvm also
Tried npm rebuild
Upgrading one of my apps from Angular 7 to 9, still same behaviour after clean install of dependencies, ensuring fsevents is installed and trying latest version too
No matter what I try, I keep observing high cpu usage, I have seen it creep up too 300-400% at times.
This is really hampering my development and I am hoping someone may have some bright ideas I could try out.
Failing that, I am wondering if I should try uninstalling node completely, getting rid of nvm and starting from scratch.
In Angular development context; transpilation/compilation causes CPU spike. When this happens too frequent, your system is in trouble.
There are certain ways to relieve the pain a little;
Turn off file change detection / live-reload / auto compilation entirely
ng serve --live-reload false or ng serve --no-live-reload etc. depending on your Angular CLI version
Have a better change detection, react only when really needed
npm install fsevents
npm rebuild fsevents
npm serve
Forget change detection, check changes based on a time interval
ng serve --poll [ms]
CPU management is tricky, there can be many reasons for this problem. These are only a few possibilities closely related to Angular development. I hope this answer provides some options to try to the ones having the same trouble.
Maybe you have similar setup for you hot/live reloading on Docker such as ng serve --host 0.0.0.0 --poll 1. The poll value is problematic, change it on something larger, for example 2000, such that ng serve --host 0.0.0.0 --poll 2000.
Now, you'll loose (almost) real-time hot/live reloading, but you'll save your CPU/battery and having 2 seconds delay before your app will refresh the changed code.
it seems i managed to resolve the problem:
delete the /node_module and install again
in my case that helped
i found the advise here:
https://gitmemory.com/issue/angular/angular-cli/14748/501608887
If you use Yarn to install packages, its lockfile may have locked in an older version of fsevents which has known issues with node-pre-gyp on Apple Silicon.
https://github.com/nodejs/node-gyp/issues/2296
Simply deleting yarn.lock, and running yarn again, should attempt to install newer versions of the fsevents dependency, which does not have that issue.
This worked with Angular 11.
Setting the flag --watch=false is what reduced CPU usage of my angular process from 50% to 0%:
ng serve --configuration=dev --watch=false

error eslint#5.6.0: The engine "node" is incompatible with this module. when trying to create-react-app

I am trying to create a React App and I am getting the following error in my console.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
yarn add v1.10.1
info No lockfile found.
[1/4] 🔍 Resolving packages...
warning react-scripts > eslint > file-entry-cache > flat-cache > circular- json#0.3.3: CircularJSON is in maintenance only, flatted is its successor.
[2/4] 🚚 Fetching packages...
error eslint#5.6.0: The engine "node" is incompatible with this module. Expected version "^6.14.0 || ^8.10.0 || >=9.10.0". Got "9.5.0"
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Aborting installation.
yarnpkg add --exact react react-dom react-scripts --cwd /Volumes/server2/Desktop/JavaScript/birdcage has failed.
Deleting generated file... package.json
Deleting birdcage / from /Volumes/server2/Desktop/JavaScript
Done.
I have tried brew upgrade node but that didn't seem to work. Any ideas on how this can be fixed would be greatly appreciated.
One of the temporally fix is to run yarn install --ignore-engines
I was facing the same issue, try to add "--use-npm" at the end of create react app commend.
create-react-app appname --use-npm
I had the same problem, simply doing this solved the problem:
npm install node#latest
Try to uninstall yarn and install it via npm.
npm i create-react-app -g
create-react-app yourappname
Make sure that node is installed!
I had the same problem, try it:
yarn config set ignore-engines true
I re-installed node and updated xcode developer tools. Also, re-installed React on that computer which is running Mojave.
Assuming nvm is installed, use it to see which version of node you're using, then use it to change to a later version.
you can change the version with nvm use <version> and then try again
In my Ubuntu 18.04 had a native version from the OS installed that not listed by NVM.
I removed it and then I ran:
Firstly run, nvm install 14.5.0
then run, nvm use 14.5.0
And the installation completed properly.
i had same issue when i was adding router plugin to vue-cli with npx and yarn as well..
In pyhton virtual environment i have updated node version from 8.x.x to 16.x.x and used command nvm use 16.x.x but still problem persists .. i was actually executing command as root .. so nvm is using node version as 8.x.x only ..
after long time i realised executing command with sudo was the issue and then executed as a normal user...
this solution worked for me !!!
As the warning said, I updated node via nvm to the version required. For me having the latest node lts version was enough.
nvm install "lts/*" --reinstall-packages-from="$(nvm current)"
But even after upgrading node, yarn still gave the error.
The problem was npm was still executed from the old .bin path of previous node version. nvm also installs latest version of npm in respective local .bin folder for the node version installed.
I used the following commands then,
nvm install-latest-npm: Attempt to upgrade to the latest working npm on the current node version
nvm install --latest-npm: After installing, attempt to upgrade to the latest working npm on the given node version
After this, it worked properly.
Reference:
How can I change the version of npm using nvm?

ERROR: npm is known not to run on Node.js v

Every time I open a terminal window, I get this (even before typing anything):
ERROR: npm is known not to run on Node.js v4.1.2
Node.js 4 is supported but the specific version you're running has
a bug known to break npm. Please update to at least 4.7.0 to use this
version of npm. You can find the latest release of Node.js at https://nodejs.org/
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v4.1.2 --silent` to unset it.
I was never running a version of node 4, but anyway I deleted node.js completely following some pretty thorough steps I found online, and then reinstalled it from the website to version 8.11.2 (node -v gives me v8.11.2) but the warning still appears
I never paid it much attention until my npm started seriously acting up while trying to work with create-react, giving me tons of security warning with npm audit and not letting me update to the indicated versions of modules.
I've tried everything, reinstalling npm, reinstalling node, etc. and I'm worried that it's interfering with my app now.
(nvm maintainer here)
If you can get node working such that nvm current doesn't say "none" or "system", then you can run nvm install-latest-npm to ensure you have the latest version of npm that actually works on your node version.
Separately, node 4.1.2 is EOL - if that's your system version, you may want to uninstall it completely.
If you're still having trouble, please file an issue on http://nvm.sh

Resources