npm not installing packages, shows E404 - npm

I am new to node and trying to install express package using npm. It throws error E404. I saw the log file and it is as follow:
Error
2 info using npm#5.6.0
3 info using node#v8.11.1
4 verbose npm-session fe4d5b2eef34bf8f
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 404 https://registry.npmjs.com/express 639ms
8 silly fetchPackageMetaData error for express#latest 404 Not Found:
express#latest

Related

npm install fails with 405 Method Not Allowed

I am currently working on upgrade some projects to use node 18 with npm 8, from node 12 with npm 6.
We're using github as npm repository for our private packages.
Now I am getting this error on npm install:
npm ERR! code E405
npm ERR! 405 Method Not Allowed - GET https://npm.pkg.github.com/<our-github-organisation>/#types/mime/-/mime-3.0.1.tgz
In the error log:
456 verbose stack HttpErrorGeneral: 405 Method Not Allowed - GET https://npm.pkg.github.com/<our-github-organisation>/#types/mime/-/mime-3.0.1.tgz
456 verbose stack at /home/cclausen/.nvm/versions/node/v18.7.0/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/check-response.js:93:15
456 verbose stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
457 verbose statusCode 405
458 verbose pkgid #types/mime#https://npm.pkg.github.com/<our-github-organisation>/#types/mime/-/mime-3.0.1.tgz
This does not happen on every package, only on a few select ones, I can't see pattern.
None of the affected patterns our ours, just random packages.
Why would this happen?
It seems the content of the .npmrc file used in the repository to specifc from where to get packages has changed, updating that file to comply with the newest information from githubs documentation has fixed this issue.
So the new content for me is:
#OWNER:registry=https://npm.pkg.github.com
Where OWNER is my organisation.

How to authenticate npm with Azure DevOps Server 2019 artifacts using IIS Basic Authentication

We have an on-premise Azure DevOps Server 2019, hosted on a Windows Server 2012 R2 Datacenter VM and IIS 8.5 with Basic Authentication enabled. We've been using Azure Artifacts packaging and feeds to publish our NuGet packages and for that we use Windows Authentication (Developers use their active directory domain username and passwords). Now, I'm trying to setup using feeds for npm.
I created a new npm project using npm init, opened the containing folder in VS Code and created a .npmrc file as Azure Artifacts told me too, then tried to install a package from the upstream package. But I get the following error:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'sass-node'
1 verbose cli ]
2 info using npm#6.10.2
3 info using node#v12.9.0
4 verbose npm-session cfab4705708e8227
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 401 http://(redacted domain name):8080/tfs/PAP%20Projects/_packaging/pap-front-end/npm/registry/sass-node 52ms
8 silly fetchPackageMetaData error for sass-node#latest Unable to authenticate, need: Bearer, Basic realm="http://(redacted local domain name):8080/tfs", Negotiate, NTLM
9 timing stage:rollbackFailedOptional Completed in 0ms
10 timing stage:runTopLevelLifecycles Completed in 99ms
11 verbose stack Error: Unable to authenticate, need: Bearer, Basic realm="http://(redacted local domain name):8080/tfs", Negotiate, NTLM
11 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\check-response.js:94:17
11 verbose stack at processTicksAndRejections (internal/process/task_queues.js:85:5)
12 verbose statusCode 401
13 verbose pkgid sass-node#latest
14 verbose cwd C:\Users\a.taravati\code\npm-test
15 verbose Windows_NT 10.0.17763
16 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "sass-node"
17 verbose node v12.9.0
18 verbose npm v6.10.2
19 error code E401
20 error Unable to authenticate, your authentication token seems to be invalid.
21 error To correct this please trying logging in again with:
21 error npm login
22 verbose exit [ 1, true ]
I didn't redact some parts on purpose, in case there exists an issue regarding them. It's notable that I search the internet and found several Q&A especially in stackoverflow and they were close to my problem but the answers were no use to me. Overall, I got the following tips:
When Basic Authentication is enabled you can't use PAT
You should encode windows password with Base64 then put it in .npmrc along with username.
I've tried them but still no luck. I'm also not sure about the following:
Should I put just username or should I use domain\username or username#domain formats?
Should I put Base64 encoded string of my password in .npmrc?
Is there a problem with the URL? the Domain? the Protocol? the collection name or feed name?
Is it possible that as long as we keep Basic Authentication enabled there won't be any chance to set this up?
Also, whenever I try to use npm login it prompts for username, password and email but then return a 400 error.

Unable to install NPM packages due to path length constraint using NPM 5.X

I'm running Windows 10, NPM v5.5.1, and node v8.9.1.
Edit: I have since updated to node v8.9.4 and npm v5.6.0. The problem remains unchanged.
I set up my development environment on this machine about 2 months ago. I'm using Angular CLI to build my client apps.
Everything was going fine. I added a few packages via NPM without a problem, such as Gulp and ngx-bootstrap. Then I started to run into errors on some of my package installs.
The errors are:
npm ERR! code PATH_LENGTH_EXCEEDED
npm ERR! errno PATH_LENGTH_EXCEEDED
npm ERR! request to https://registry/npmjs.org/{{package}} failed, reason: path length constraint exceeded
npm ERR! A complete log of this run can be found in:
npm ERR! {{npm_cache path}}\_logs\2018-02-08T14_43_40_856Z-debug.log
The contents of that log file are:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'ngx-cookie-service',
1 verbose cli '--save' ]
2 info using npm#5.5.1
3 info using node#v8.9.1
4 verbose npm-session d55be12849534a0a
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for ngx-cookie-service#latest request to https://registry.npmjs.org/ngx-cookie-service failed, reason: path length constraint exceeded
8 verbose type system
9 verbose stack FetchError: request to https://registry.npmjs.org/ngx-cookie-service failed, reason: path length constraint exceeded
9 verbose stack at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\index.js:68:14)
9 verbose stack at emitOne (events.js:116:13)
9 verbose stack at ClientRequest.emit (events.js:211:7)
9 verbose stack at TLSSocket.socketErrorListener (_http_client.js:387:9)
9 verbose stack at emitOne (events.js:116:13)
9 verbose stack at TLSSocket.emit (events.js:211:7)
9 verbose stack at emitErrorNT (internal/streams/destroy.js:64:8)
9 verbose stack at _combinedTickCallback (internal/process/next_tick.js:138:11)
9 verbose stack at process._tickCallback (internal/process/next_tick.js:180:9)
10 verbose cwd C:\Development\test
11 verbose Windows_NT 10.0.15063
12 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "ngx-cookie-service" "--save"
13 verbose node v8.9.1
14 verbose npm v5.5.1
15 error code PATH_LENGTH_EXCEEDED
16 error errno PATH_LENGTH_EXCEEDED
17 error request to https://registry.npmjs.org/ngx-cookie-service failed, reason: path length constraint exceeded
18 verbose exit [ 1, true ]
I researched this, and found the Windows 10 file path 260 character limitation. I thought that npm version 3.1.0 should have fixed this issue, but I decided to followed the instructions in this answer, because I'm still running into this issue despite using NPM v5.5.1.
I found that my version of Windows was prior to the roll out of the feature that lets you disable this limitation. I updated to Version 1703 (OS Build 15063.483), and to enable Win32 long paths.
Yet I'm still getting the error, and unable to install a variety of npm packages.
In testing to see if it was an issue with packages that have a lot of dependencies, I tried installing or reinstalling a couple of other packages.
Some fail with the errors above. Others succeed with the following warnings:
npm WARN Unexepcted warming for https://registry.npmjs.org/: Miscellaneous Warning PATH_LENGTH_EXCEEDED: request to https://registry.npmjs.org/{{package name}} failed, reason: path length constraint exceeded
npm WARN Using stale package data from https://registry.npmjs.org/ due to a request error during validation
Packages throwing the error include:
jslint
ngx-cookie-service
chart.js
angular-cli
Packages that throw the warnings include:
font-awesome
#angular/cli
moment
ngx-bootstrap
bootstrap
jasmine
I suspect that something has changed, either in a policy on my workstation, or in our network security, that is causing this. All of the packages that succeed seem to be packages that I had previously installed, either as a direct install, or as a dependency of #angular/cli (one of the first packages I installed). I'm assuming that the stale package data warning indicates that whatever problem I have with the path length is preventing updated data being retrieved, and therefore npm is falling back to cached data from previous installations of the selected package and its dependencies.
So now I'm stumped as to how to diagnose exactly where the issue is happening. If its a security policy that changed, then I need to be able to describe exactly what is being blocked so that I can work with our security department to fix this. But the only information I can find about the PATH_LENGTH_EXCEEDED errors lead me to old information about versions of npm prior to 3.1.0.
How can I identify the source of this problem?
After additional searching, I found references to path length exceeded with regards to SSL/TLS certificate authorities. I tested this issue by changing the npm registry to use http instead of https (note: this is a temporary step only; I have turned https back on once I verified the issue):
npm config set registry http://registry.npmjs.org/
This allowed me to install the problematic packages.
It seems the underlying cause is SSL Inspection performed by our network security team. The decryption, inspection, and re-encryption process, and subsequent changes in the Issuing Authority on the certificate, apparently triggers this error.

npm install error - cb() never called

I try to install node_module in my angular project what I downloaded, but I get this error:
npm ERR! registry error parsing json
Then i reinstall npm using npm intall npm -g and after when i try use npm install I get this error:
(node:11252) UnhandledPromiseRejectionWarning: Unhandled promise
rejection (rejection id: 1): Error: ENOENT: no such file or directory, stat
'C:\Users\User\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-ec5da46c\angular\cdk.es5.js'
debug.log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install' ]
2 info using npm#5.4.2
3 info using node#v6.10.2
4 verbose npm-session ff5ce249dfe37f0e
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall spa#0.0.0
7 info lifecycle spa#0.0.0~preinstall: spa#0.0.0
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 silly install loadShrinkwrap
13 info lifecycle #angular/cdk#2.0.0-beta.10-a7ce31e~prepack: #angular/cdk#2.0.0-beta.10-a7ce31e
14 error cb() never called!
15 error This is an error with npm itself. Please report this error at:
16 error <https://github.com/npm/npm/issues>
I already tried npm cache clean --force but i get same error.
node -v v6.10.2
npm -v 5.4.2
I had the same issue. I resolved it
by excluding package-lock.json file
npm i --no-package-lock
OR by manually deleting package-lock.json
Run npm cache clean --force and perform an install.
I had the same issue. I resolved it by remove nodejs#10 and install nodejs#8
On Windows 10 running npm install gave me this error.
I solved this issue by doing so from within Administrator: Command Prompt.
Ensure that you have a package.json file within the root of your angular project which should look something similar to this.
https://github.com/heroku/node-js-sample/blob/master/package.json
If the package.json file exists, you run npm install to get the packages saved to it and that will generate a node_modules directory for you.
However, if the file does not exist, it means you have to initialize npm into the project by running npm i -y which should automatically create a package.json file for you and as well allow you to install node modules.
NB: You have npm installed on your machine already so running npm install npm -g is not ideal.
I got this error when my package.json referred to a package using file:../(local path) and the directory didn't exist. Pointing it to the correct path resolved the error.
In my case... none of the above worked. I then deleted my package-lock.json. When I ran an npm install I got an error that a certain package could not be found in the repository. When I removed that from package.json my npm install worked!
I had the same issue. In my case it was caused by a syntax error within the .npmrc file, which was manually edited
Method 1:
npm cache clean --force then install your package
Method 2:
Disable your antivirus software and try to install your package
Method 3:
It is your internet connection, if you are using Wifi or an Ethernet connection use your cellular network or a different network and try to install your package

npm install error - setting dev env

trying set up dev env for kibana
i cloned kibana ; cd kibana
and run npm install
getting the following error :
C:\kibana>npm install
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program
Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "elasticsearch"
19 error node v6.10.3
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error kibana#6.0.0-alpha2 elasticsearch: `grunt esvm:dev:keepalive`
22 error Exit status 1
23 error Failed at the kibana#6.0.0-alpha2 elasticsearch script 'grunt esvm:dev:keepalive'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the kibana package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error grunt esvm:dev:keepalive
23 error You can get information on how to open an issue for this project with:
23 error npm bugs kibana
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls kibana
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]