npm not working after clearing cache - node.js

Before clearing cache
npm cache clear
npm is working fine. After clearing cache, it is not working.
The error log below suggest problem with internet connectivity but internet connection is just fine.
This problem does not only happen for bower but for any modules.
Here's the output of process:
> sudo npm install -g bower Password: npm http GET
> https://registry.npmjs.org/bower npm http GET
> https://registry.npmjs.org/bower npm http GET
> https://registry.npmjs.org/bower npm ERR! network connect ETIMEDOUT
> npm ERR! network This is most likely not a problem with npm itself npm
> ERR! network and is related to network connectivity. npm ERR! network
> In most cases you are behind a proxy or have bad network settings. npm
> ERR! network npm ERR! network If you are behind a proxy, please make
> sure that the npm ERR! network 'proxy' config is set properly. See:
> 'npm help config'
>
> npm ERR! System Darwin 12.5.0 npm ERR! command
> "/usr/local/Cellar/node/0.10.16/bin/node" "/usr/local/bin/npm"
> "install" "-g" "bower" npm ERR! cwd /Users/username npm ERR!
> node -v v0.10.16 npm ERR! npm -v 1.3.8 npm ERR! syscall connect npm
> ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! npm ERR!
> Additional logging details can be found in: npm ERR!
> /Users/username/npm-debug.log npm ERR! not ok code 0

This worked for me:
npm cache clean --force

It should be
npm cache clean
See https://docs.npmjs.com/cli/cache.html

"As of npm#5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use
npm cache verify
instead."

try this one
npm cache clean --force
after that run
npm cache verify

Try npm cache clean --force if it doesn't work then manually delete %appdata%\npm-cache folder.
and install npm install npm#latest -g
It worked for me.
visit this link

I try to
npm cache clean
But npm said newer version on npm (> 5) has self healing Mechanism
and every thing i need to do for checking npm is use verify
npm cache verify
npm message :
The npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid.
If you want to make sure everything is consistent, use 'npm cache verify' instead.
but for forcing npm use this:
npm cache clean --force

Try npm cache clean --force if it doesn't work then manually delete %appdata%\npm-cache folder.

Environment path may have been removed.
Check it by typing,
npm config get prefix
This must be the location where the npm binaries are found.
In windows, c:/users/username/AppData/Roaming/npm is the place where they are found.
Add this location to the environment variable. It should work fine.
(Control Panel -> Search for 'Environment Variables' and click on a button with that name -> edit Path -> add the above location)

at npm#6.8.0 the command that is been supported is npm cache verify

I solved this issue by running cmd as an administrator.
before that, I was trying to run in vs code.
run it in Power Shell or Cmd with administrative privilege. I hope that it will help.
npm install –g #angular/cli#latest

npm cache clean --force
or
npm cache clean
after that run
npm cache verify

npm install --cache /tmp/empty-cache

rm C:\Users\<User>\AppData\Local\npm-cache\

Related

npm ERR! cb() never called

I was trying to download expo cli and I got error:-
C:\WINDOWS\system32>npm i -g expo-cli
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://github.com/npm/cli/issues>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HP\AppData\Local\npm-cache\_logs\2021-03-03T14_02_14_809Z-debug.log
I also used npm cache clean --force.
But it didn't work too😥
C:\WINDOWS\system32>npm -v
7.6.0
C:\WINDOWS\system32>node -v
v14.16.0
Please help me......
And after doing npm i -g npm it worked!!!!!!
But when I tried to install or download any packages then error:
E:\React-native\practice>npm i react-native-elements
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://github.com/npm/cli/issues>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HP\AppData\Local\npm-cache\_logs\2021-03-04T05_03_20_067Z-debug.log
So what is wrong going on?
If you are using npm version 5 or above:
Try following command:
$ sudo npm cache verify
OR
$ sudo npm cache clean --force
I've had the same problem, and was able to fix it by adding the flag --legacy-peer-deps to the installation command. For instance:
npm i --legacy-peer-deps package-name
Run npm install -g npm & npm cache clean
I had the same problem and solved it with checking my proxxy settings in C:\Users\username.npmrc
here are the settings for the proxy.
proxy=...
https-proxy=...
strict-ssl=false
registry=...
You can set these things through npm with the following:
npm config set proxy ...
npm config set https-proxy ...
npm config set strict-ssl false
npm config set registry ...
Maybe you have to remove proxy and https-proxy to make it work.
I had the same problem in all npm package that I tried to download, and solved just running this command in my Windows CMD.
npm set strict-ssl true
You can try to force clean the npm cache
npm cache clean --force
I did the following steps:
delete node_modules
remove package-lock.json
run npm cache clean --force
run npm install --force
npm install --force was the key to success, because even after doing 1-2 steps, normal npm install resulted in same problem

npm install always gives 'Your cache folder contains root-owned files, due to a bug in npm previous versions of npm which has since been addressed.'

I am currently using Ubuntu 18.04.4 and I am trying to install something using npm install but it always gives the error below. I tried other aliases as well (npm i, npm add) but the error persists.
npm install
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path /home/dell/.npm/_cacache/content-v2/sha512/14/21/2143fe2b135cd8bfdad85c9c3f9ac46ab279a58dee631cfea1b9678167bd388d44f2d36739019c96ba3a4c4756b1ea6570f4dc8931fb8ad8230359521f80
npm ERR! errno -1
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1001:1001 "/home/dell/.npm"
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dell/.npm/_logs/2020-07-30T17_16_58_257Z-debug.log
When I run the sudo chown -R 1001:1001 "/home/dell/.npm" command, it does nothing, and the error remains when I run npm install again. I have also searched StackOverflow and other platforms for the answer, but no solution seems to solve this problem.
P.S: My node version is 12.18.3 and npm version is 6.14.6.
If someone can help me resolve this, I would really appreciate it!
I had problem with create-react-app. Solve it using yarn.
yarn global remove create-react-app
then
yarn global add create-react-app
and
create-react-app MyApp

unable to install firebase tools cli using windows 10

Hi i unable to install the firebase tools via commandline in the windows
im using this below command
npm install -g firebase-tools
after entering this command i m getting this below error
npm ERR! path C:\Users\data\AppData\Roaming\npm\node_modules\firebase-tools\node_modules
npm ERR! code ELOOP
npm ERR! errno -4067
npm ERR! syscall mkdir
npm ERR! ELOOP: too many symbolic links encountered, mkdir 'C:\Users\data\AppData\Roaming\npm\node_modules\firebase-tools\node_modules'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\data\AppData\Roaming\npm-cache_logs\2018-01-20T13_22_41_404Z-debug.log
Latest version seems to have a problem.
Try installing one previous version:
npm i -g firebase-tools#v3.17.2
UPDATE:
Before doing so, it might be better to uninstall faulty one:
npm uninstall -g firebase-tools
also make sure you have windows-build-tools installed (though I have it on my machines, error you share doesn't really seem to be related to this)
npm --add-python-to-path='true' --debug install --global windows-build-tools
UPDATE 2
I've updated my Node & NPM versions and then to latest Firebase Tools.
Still getting WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1 error, but since it's a warning, I've decided to give it a try. So far no problems.
UPDATE 3
windows-build-tools package got an update yesterday so I installed it with hope it solves problems installing latest version of firebase-tools. It did not, same errors occur.
Actually you can try installing the
npm i -g firebase-tools#v3.16.0 version and try to install the
npm install windows-build-tools**in your local folder and after that install
**npm install node-gyp in your local folder and before doing all these try to disable your antivirus
npm ERR! code E404 npm ERR! 404 Not Found - GET https://registry.npmjs.org/#google-cloud%2fpubsub/firebase-tools/firebase-tools npm ERR! 404 npm ERR! 404 'firebase-tools#latest' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\jsmma\AppData\Roaming\npm-cache_logs\2020-05-02T14_58_23_615Z-debug.log

npm ERR! Cannot read property 'path' of null

**C:\Users\Abc>npm install -g
npm ERR! addLocal Could not install C:\Users\Abc
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe"
"C:\Users\Abc\AppData\Ro
aming\npm\node_modules\npm\bin\npm-cli.js" "install" "-g"
npm ERR! node v7.2.1
npm ERR! npm v4.0.5
npm ERR! Cannot read property 'path' of null
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Abc\npm-debug.log**
i have reinstall node with version 7.2.1
after every time this occurs when i download any package
need suggestion related to null path error
I ran into this issue while installing gulp
My NPM and Node Versions are:
node v7.7.4
npm v4.1.2
In npm version 4x, https client certificates were made required rather than optional. Details are in their github area.
Long story short, what helped for me was running the following command:
npm config set strict-ssl false
Once this was done, running the command
npm install gulp -g
Worked like a charm for me!
If you are working behind proxy, you need to set proxy for nodejs
npm config set proxy http://proxy_host:port
npm config set https-proxy http://proxy_host:port
Hope it Helps.. :)
npm install command is used to install packages.
Reason for your error :
You don't have any package.json in your current working directory.
Also, you didn't provide any package name to install from.
Tips :
Check out https://docs.npmjs.com/cli/install for more details.
Never use -g (install dependency globally unless you intend to).

Can't install any packages in Node.js using "npm install"

I'm new to Node.js, and I'm going through a few tutorials.
For some reason, I can't install any new node modules.
I am using:
Mac OSX 10.7.4,
Node v. 0.8.6,
NPM v. 1.1.48.
I run npm install X and I always get a
npm ERR! fetch failed https://registry.npmjs.org/-/X
npm ERR! Error: 404 Not Found
When I actually go to the npmjs registry, I can see the project page, but no matter which tarball link I hit, it's always the same:
{
"error": "not_found",
"reason": "document not found"
}
For example, I tried installing fs by running npm install fs and I get:
npm http GET https://registry.npmjs.org/fs
npm http 200 https://registry.npmjs.org/fs
npm http GET https://registry.npmjs.org/-/fs-0.0.0.tgz
npm http 404 https://registry.npmjs.org/-/fs-0.0.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/-/fs-0.0.0.tgz
npm ERR! Error: 404 Not Found
npm ERR! at null.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/fetch.js:47:16)
npm ERR! at EventEmitter.emit (events.js:115:20)
npm ERR! at WriteStream.flush (fs.js:1514:12)
npm ERR! at fs.close (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:92:5)
npm ERR! at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "fs"
npm ERR! cwd /Users/comocomo/Documents/workspace/nodeTest
npm ERR! node -v v0.8.6
npm ERR! npm -v 1.1.48
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/comocomo/Documents/workspace/nodeTest/npm-debug.log
npm ERR! not ok code 0
I tried fs, fs-extra, express, and formidable, all giving me the same 404 response.
There must be something wrong on my part, I'm pretty sure the whole registry is not broken.
Am I using an old registry? Should I change it in my config file? I honestly would rather not start installing things manually, and I'm sure it's just a small configuration issue.
Thanks!
I found the there is a certificate expired issue with:
npm set registry https://registry.npmjs.org/
So I made it http, not https :-
npm set registry http://registry.npmjs.org/
And have no problems so far.
The repository is not down, it looks like they've changed how they host files (I guess they have restored some old code):
Now you have to add the /package-name/ before the -
Eg:
http://registry.npmjs.org/-/npm-1.1.48.tgz
http://registry.npmjs.org/npm/-/npm-1.1.48.tgz
There are 3 ways to solve it:
Use a complete mirror:
Use a public proxy:
--registry http://165.225.128.50:8000
Host a local proxy:
https://github.com/hughsk/npm-quickfix
git clone https://github.com/hughsk/npm-quickfix.git
cd npm-quickfix
npm set registry http://localhost:8080/
node index.js
I'd personally go with number 3 and revert to npm set registry http://registry.npmjs.org/ as soon as this get resolved.
Stay tuned here for more info: https://github.com/isaacs/npm/issues/2694
Npm repository is currently down.
See issue #2694 on npm github
EDIT:
To use a mirror in the meanwhile:
npm set registry http://ec2-46-137-149-160.eu-west-1.compute.amazonaws.com
you can reset this later with:
npm set registry https://registry.npmjs.org/
source
This error might also occur due to proxy settings, once check that your proxy allow the access to npm commands.
It worked for me quite well.
npm set registry http://85.10.209.91/
(this proxy fetches the original data from registry.npmjs.org and manipulates the tarball urls to fix the tarball file structure issue).
The other solutions seem to have outdated versions.
If you happened to run npm install command on Windows, first make sure you open your command prompt with Administration Privileges. That's what solved the issue for me.
Check under security settings
Allow Apps Downloaded from:
App Store and other identified developers
This was one of the reasons I faced recently.

Resources