getting code E401 error after running 'npm install' - node.js

I'm trying to clone a ReactJs project by git clone, and after open the project in VS CODE and run 'num install' I'm facing with code E401 error with the following sentence:
npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be invalid.
npm ERR! To correct this please trying logging in again with:
npm ERR! npm login
after I try to login I'm getting this error:
npm ERR! code E400
npm ERR! 400 Bad Request - PUT https://...
I saw that my account in vs code in not connected, so I logged in and still same error.
After a few hours of searching for a solution I realized that it was related to the .npmrc file, because other projects that doesn't have the npmrc file works fine, but I can't understand what is the problem exactly.
My .npmrc file is look like:
registry=https://...
always-auth=true
I'm tried to remove it, and delete package-lock.json and still not working.

Related

error npm ERR! code FETCH_ERROR npm ERR! errno FETCH_ERROR npm ERR! invalid json response body when installing reactjs

so im trying to learn ReactJS, but when i looked up to ReactJS docs, it says install with
npx create-react-app {project_name}
it also required nodejs & npm, i have installed node js latest version & npm. but when i run the command, it alwasy getting the same error, the error says
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/#types%2fsemver reason: Invalid response body while trying to fetch https://registry.npmjs.org/#types%2fsemver: EBUSY: resource busy or locked, rename 'C:\Users\AGUS\AppData\Local\npm-cache\_cacache\tmp\d5e89a99' -> 'C:\Users\AGUS\AppData\Local\npm-cache\_cacache\content-v2\sha512\5f\16\d22537befb8a38d3af73438bd2409a960900a502346287a0a0fa17784814bd2664f39eeb0107aa02ac292aeb51d7f52f4a90db5325d9b47bc8f5ce1538ca'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AGUS\AppData\Local\npm-cache\_logs\2022-11-02T08_20_55_473Z-debug-0.log
i have searched up this problem but its not solved, always error.
please help me solve this problem :(
i have tried uninstall & reinstall node, still not working,
i tried npm cache clean --force & npm cache verify still not working, thank you:)
Try :
npm cache verify
npx create-react-app {project_name}
I had the same error and these steps solved it.
√ Would you like to use src/ directory with this project? Yes
√ Would you like to use experimental app/ directory with this project? Yes
√ What import alias would you like configured? ... #/*
and also ensure that no background apps are running

Trying to install axios on a React project via npm i axios

When I run npm i axios I get the following errors:
C:\Users\Mary\star-wars>npm i axios
npm ERR! code E404
npm ERR! 404 Not Found - GET https://skimdb.npmjs.com/registry/axios/-/axios-0.27.2.tgz - not_found
npm ERR! 404
npm ERR! 404 'axios#https://skimdb.npmjs.com/registry/axios/-/axios-0.27.2.tgz' is not in this registry.
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\Mary\AppData\Local\npm-cache_logs\2022-07-07T14_23_38_747Z-debug-0.log
I can´t find anything that works for me, I´ve tried to reinstall dependencies, I´ve tried to unistall axios and re-install it without success.
I´ve checked the log & it contains the same error that shows when I run the command.
Has anyone found a solution for this?
I was finally able to do what I intended by running it as Admin, creating a different folder, running npm cache clean -f and setting npm. registry
After that, everything went smooth.

Why is npm publish telling me the package doesn't exist?

I'm trying to upload an npm package to a GitLab registry for the first time. I set the scope and the npm config entries according to the documentation, but when I execute npm publish, I get the following error:
npm notice Publishing to https://git.myorg.com/api/v4/projects/123/packages/npm/
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://git.myorg.com/api/v4/projects/123/packages/npm/#myscope%2fmyproject
npm ERR! 404
npm ERR! 404 '#myscope/myproject#1.0.0' is not in this 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.
So I try to publish it, and the error says it doesn't exist and that I should publish it...what?!
From the last two lines it looks like the error is meant for an installation failure, but I have definitely used npm publish. Also, in the PUT command, the final slash between scope and project name is replaced with %2f. No idea why that happened and why it happened nowhere else, but maybe that is a symptom of the underlying issue?
Ok, it was my own fault. When executing npm config set #foo:registry https://gitlab.example.com/api/v4/projects/<your_project_id>/packages/npm/, I put in the group ID instead of the project ID in the place of <your_project_id>. We use the group only for the package registry project, so I got them confused.

Installing npm private package gives back 404/405 - "is not in the npm registry"

npm ERR! code E404
npm ERR! 404 Not Found - GET http://registry.npmjs.org/#office%2fintegration-sdk - Not found
npm ERR! 404
npm ERR! 404 '#office/integration-sdk#*' 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.
We have private bitbucket repo, with package code, that we want to make npm private package out of it.
I've managed to publish it thru CLI with npm publish, and with the bitbucket pipeline.
And it can be installed fine, as long as i am logged in with npm login.
But we want to be able to install it without logging to npm(when deployed etc..), and i thought NPM_TOKEN is there for those reasons.
I've tried buncha stuff in .npmrc file, mostly like:
#office:registry=https://registry.npmjs.org/:_authToken=<'read/publish token from npm'>
Steps:
npm publish
check npm - package looks good, updated, etc..
run install command - npm i #office/integration-sdk
Fails with either 404(most of the time), and with 405 Method not Allowed when i have #office:registry=https://registry.npmjs.org/#office.
One thing that might be causing this.. We only have user account on npm i guess, it is Pro account with private packages thing. But we didn't create organization. Could that be a problem, i mean it can be published, and installed when logged in, and also public packages can be installed just fine when not logged in.

NPM install failing with 502 error

This is a rather obscure issue. I have an Angular app that will be running through Codeship for CI. However, when it comes time to run npm install on the Codeship box, npm gives back
-npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
\npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
\npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm ERR! Linux 4.2.0-38-generic
npm ERR! argv "/home/rof/.nvm/versions/node/v4.1.1/bin/node" "/home/rof/.nvm/versions/node/v4.1.1/bin/npm" "install"
npm ERR! node v4.1.1
npm ERR! npm v2.14.4
npm ERR! fetch failed with status code 502
This was quite strange, since the npm install worked just fine on my box. My first instinct was that it had to be an issue with the NPM repository, so I grabbed the url for the package(https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz) and threw it into a new Chrome tab. Sure enough, the archive downloaded almost instantly. I was confused by this, so I tried the Codeship build again, but got the same results. I decided to SSH into the Codeship box to see if I could access it. I ran
curl https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
and as I expected I got the 502 error. However, when I ran the same command from the terminal on my machine, I got the same result, even though the npm install ran perfectly for me. I wasn't able to find anyone else having this type of an issue, and a 502 seems like a very rare code for the NPM registry to be returning. Any ideas?
This is a problem with the registry.npmjs.org in some regions.
Here is issue:
https://github.com/npm/npm/issues/13284
Try to keep one registry inside .npmrc file, only one of them works.
The order of registry also does matter. Also try to set:
npm config delete proxy
npm config delete https-proxy
to clean proxy inside terminal.
I'm seeing the same issue via npm install on Ubuntu 14 running on AWS
curl https://registry.npmjs.org/combine-lists/-/combine-lists-1.0.0.tgz
returns 502 Bad Gateway from the ubuntu server, but works fine from local client
There's an open issue at NPM for this:
https://github.com/npm/npm/issues/13284
NPM just acknowledged the issue and they are working on it. Your can track the status at below link.
http://status.npmjs.org
I got this error while publishing my package on npm. After banging my head against the wall for a few hours, I realized I was on mobile hotsopt. I switched to wifi and bang there was my package on npm!

Resources