npm install errors out on all packes if npm-shrinkwrap.json is present - npm-install

node v10.15.0
npm v6.4.1
I inherited a project that has an npm-shrinkwrap.json next to the package.json.
When I run npm install I get errors like the following for the files in every single package that should be downloaded
npm WARN tar ENOENT: no such file or directory, open 'C:\...\node_modules\.staging\core-js-12a70f6a\fn\number\virtual\index.js'
Checking the .staging folder I see that the files are actually there!
Out of curiosity I removed the npm-shrinkwrap.json and run npm install again and now it creates the node_modules folders as expected.
I found that shrinkwrap is an old method, replaced by the lock mechanism in later NPM versions?
Would it be save to just delete the npm-shrinkwrap.json and not run into any issues with package versions later?

Related

prevent npm from removing node_modules folder on failure

I want to npm install a broken package, i.e., the installation process does not work properly and results in an error. I am used to npm keeping the successfully installed packages in the local node_modules folder. For some reason npm has stopped doing that and removes the node_modules folder if the install is not successful.
How can I tell npm to keep the local node_modules folder regardless of the success or failure of the installation process?
I faced a similar problem when one of the packages failed to build its C++ addon and npm removed node_modules. The below steps helped me:
Install the packages with scripts disabled.
$ npm install --ignore-scripts
Fix the package
...
Rebuild the package
$ npm rebuild PACKAGE

"PulseTile-RA" cannot run. Is it an npm dependency issue?

I wanted to experiment with this project based on react-admin:
https://github.com/PulseTile/PulseTile-RA
So I downloaded the code, run npm install and I got a lot of errors from NPM mainly axios version corrupted.
Example:
npm ERR! code EINTEGRITY
npm ERR! sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI= integrity checksum failed when using sha1: wanted sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI= but got sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g== sha1-/z8N4ue10YDnV62YAA8Qgbh7zqM=. (75833 bytes)
npm WARN tarball tarball data for js-yaml#3.13.1 (sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==) seems to be corrupted. Trying one more time.
npm ERR! code EINTEGRITY
npm ERR! sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ== integrity checksum failed when using sha512: wanted sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ== but got sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==. (74050 bytes)
npm WARN tar ENOENT: no such file or directory, open 'C:\nodejs\xxx\PulseTile-RA\node_modules\.staging\babel-plugin-transform-object-rest-spread-7e34a6f0\package.json'*
When I do npm start I get an error that react-scripts doesn't exist.
I tried workarounds for similar errors on stackoverflow but without success. And yet still, I cannot get it to run. I have latest NPM, node on windows 10.
Please advise on NPM issues as I think this is the source of this project issue of not starting.
Thank you
So technically, this has more to do with npm than the actual project.
In fact, this issue reported to the npm repository would help.
But here are some quick steps that should help:
Since you're in windows-10, it's advisable to run the "delete" commands within git bash.
Go to the project directory (root folder)
Delete the node_modules directory: rm -rf node_modules
Delete package-lock.json file:rm package-lock.json`
Clear the cache: npm cache clean --force
Run npm install --verbose
If it doesn't help, then please follow more instructions here

I deleted a package folder under node_modules by mistake

I deleted a folder under node_modules by mistake, should I run npm install in the project root to recover the deleted files without deleting the entire node_modules folder or should i delete the node_modules first and then run npm i?
If I run npm install without deleting the node_modules folder; will npm install only add the missing package files under the node_modules?
You probably must be having package.json present in your project root directory. If you have so, then you can then directly run npm install and all the packages and dependencies will be restored.

NPM: ENOENT: no such file or directory, rename

I was using gulp on the project, then i decide to deleted all the dev dependencies to switch to webpack, but every time i try to install using npm is get this error:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\fsevents-e80c4ef4\node_modules\are-we-there-yet' -> 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\are-we-there-yet-5db4c798'
npm ERR! path C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\acorn
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\acorn' -> 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.acorn.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\MiguelFrias\AppData\Roaming\npm-cache\_logs\2018-04-04T11_54_23_587Z-debug.log
any idea what can be happening.
just delete package-lock.json file and then install packages, that's all you need and should be works
rm package-lock.json && npm i
When I got this error I looked for all running instances of node in my task manager (i use process explorer on windows) and close/kill all running instances of node. For me its often webstorm or vs code. After closing these programs and ensuring there is no running node process npm install works again.
cache verify command resolved the issue for me
npm cache verify
I remove node_modules and package_lock.json. Then, npm install and it works
Iam using
-node v15.5.0
-npm v6.14.10
Try this:
close "expo start"
remove "package-lock.json"
Try to install packages now
example: npm i #react-navigation/native
This will fix the issue.
The simplest fix for me was:
npm uninstall -g
Then:
npm install -g
The second line may give a hint on what's happening:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\fsevents-e80c4ef4\node_modules\are-we-there-yet' -> 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\are-we-there-yet-5db4c798'
It looks like npm doesn't have enough permission on the folder you're trying to use.
You can try:
Delete the npm_modules again.
Open whatever editor/terminal you're using to npm install with admin permission.
I found a solution for the problem, apparently is some kinda problem with the last version of npm, i was using npm version 5.6.0 and i downgraded to npm version 5.3.0. This did work after all, after intall a couple packages i still get the same error.
ok change version of npm for the last version 5.8.0 now everything working just perfect, before was some kind of problem with atom that denied the permission the building process to install the dependencies of the package.
I just retried to run
npm install
and it succeeded
For me, package-lock.json was not created and script was failing before itself.
This fixed my issue:
- deleted my node_modules.
- npm cache clean
- opened cmd as administrator at the repository folder
- logged-in to the https://registry.npmjs.org/ using username and passoward as few of my components needed authentication to install.
- npm i
If you ever get this error, the hotfix is to follow these steps:
delete node-modules folder
run command npm cache clean --force
run command npm install
install the package again with npm install your-package-name
Actually the current package you are installing has some dependencies which is not being found my npm. So, before installing this package just perform the following command. (It will install all your listed dependencies mentioned in package.json file which are necesaary to run your application)
npm install
It works...!
For not to delete package-lock.json or node_modules every time, just add file ".npmrc" with content "package-lock=false", or add this string if file ".npmrc" already exists.
You can try by removing the package-lock.json with the command rm package-lock.json then you go to the Node.JS website you 'install it' by going to LTS then after your node is updated run npm install in your terminal and that worked for me.
Just update the node to the latest version.
It solved my problem.
I was running command in Ubuntu wsl and it wasn't working so i tried running in cmd prompt and it worked
Kindly check any package.json is open anywhere, then close it first then retry.
For me I just deleted both package-lock.json & node_modules folder. Now everything works great 😃
Another thing I've seen a lot on projects that have been around and gone through multiple contributors:
Double check to see if anyone on your team has simultaneously done a npm install and yarn.
The tell-tale sign is you'll see a package-lock.json (generated by npm) and yarn-lock.json (generated by yarn) in the same repo. This can cause side-effects from collisions in the node_modules folder.
You can try dumping that folder locally, establishing a package manager of choice for your project and instructing the whole team on best practices.
For me I had to sudo the npm install command. Don't know why... Don't want to know either.
sudo npm install --save-dev my_package
These steps work for me:
1. run "npm cache verify" or
2. remove node_modules and package-lock.json
and rerun command)
Sometimes it can be the fault of the package you are trying to install. If that package is a local package and has a node_modules folder. Try:
cd /path/to/package
rm -rf package-lock.json npm-shrinkwrap
npm install
Happen to me when I was coding react native app with expo,
when I was run the app and try to install form npm happen that error.
So just stop run the app and reinstall the package
for me it work fine
Updating npm to latest version worked for me.
A combination of the answers from above worked for me:
Restart the computer ( in my case WSL );
Run the commands from bellow from your chosen terminal, not from VSCode terminal
npm cache clean -f
rm -rf node_modules
rm package-lock.json
npm install
Good luck! :) ✌
Dont run cmd in root of a directory.
there might be one directory inside which u try to run.
cd Directory
npm i
In may case, it was next-i18next.config.js,
that had duplicated languages in the locales value,
and fallbackLng with existing languages refer to existing languages.
This works for me,
rm -rf ./**/node_modules
while I need lerna bootstrap
This worked for me (on command line in Ubuntu):
Update Node using
sudo npm install -g n
followed by
sudo n 16.13.2
Closed and reopened shell, cd back into the correct repo and then
sudo install npm -g
Deleting package-lock.json or node_modules & After running:
npm install -g npm
it is working for me.

How can I install Foundation for Sites correctly with npm?

I would like to create a template based on the Foundation Zurb template which can be updated easily. So my first thought was to use npm to get the package and specific versions.
The "Foundation for Sites" documentation says that Foundation can be installed with the command:
npm install foundation-sites.
If I call this command in an empty directory I get the following output:
npm WARN saveError ENOENT: no such file or directory, open '/home/robert/Documents/blog/src/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/robert/Documents/blog/src/package.json'
npm WARN src No description
npm WARN src No repository field.
npm WARN src No README data
npm WARN src No license field.
+ foundation-sites#6.4.3
Afterwards I see the following files/directories:
node_modules/
package-lock.json
From the documentation I would have expected this:
It occurs to me that I'm missing some understanding.
Is that a reasonable way to "build" the package?
npm installs dependencies into node_modules.
You want to use one of the templates eg https://github.com/zurb/foundation-zurb-template or https://github.com/zurb/foundation-sites-template which you can install using foundation-cli.