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

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.

Related

Protractor Error - #types/jasmine' is not in the npm registry

I am trying to install protractor but receiving following error.
command:
npm install -g protractor
npm ERR! node v4.4.3
npm ERR! npm v2.15.1
npm ERR! code E404
npm ERR! 404 no such package available : #types/jasmine
npm ERR! 404
npm ERR! 404 '#types/jasmine' 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 It was specified as a dependency of 'protractor'
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! Please include the following file with any support request:
npm ERR! F:\temp\chrome downloads\npm-debug.log
I came across this issue today and my problem was that I had set a custom registry within the npm config file. Have you ever used "npm set registry"?
If so, you can manually tell npm where to look for the '#types' registry with the following command:
npm config set #types:registry https://registry.npmjs.org/
The problem is coming from the fact that you're using a private registry that has not yet added support for #organization packages.
In my case, I was using Sonatype Nexus and my version didn't have support for those types of packages. #Willie Valdez's suggestion is probably the best solution for you, right now.
Also, check if you have a .npmrc file in your home directory or in your project directory. The registry might be there. If that's the case, just rename the file to npmrc_bak or something else until you install the package and then revert back to its original name.
You can also include a .npmrc file in your current project with the below details:
#angular:registry=https://registry.npmjs.org
#types:registry=https://registry.npmjs.org
#ngtools:registry=https://registry.npmjs.org
#angular-cli:registry=https://registry.npmjs.org
its handy and resuable across new projects.

Can't run npm install in an Ember CLI application?

I am setting up an Ember application on a new laptop. I installed node, npm through brew and I also have the Ember CLI. Within the Ember CLI app, I'm trying to do an npm install but when I do, I get this error in the terminal:
npm WARN package.json npm#1.4.21 Non-dependency in bundleDependencies: inherits
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.10.33
npm ERR! npm v2.1.11
npm ERR! code E404
npm ERR! 404 Not Found: expresss
npm ERR! 404
npm ERR! 404 'expresss' 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 It was specified as a dependency of 'ember-cli'
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! Please include the following file with any support request:
npm ERR! /Users/Nagarjun/Code/sumo-list/web-client/npm-debug.log
I can't run my projects until this is resolved. What am I missing? I even Googled but couldn't find anything for expresss.
My guess is 'expresss' (with an extra s) is a package on npm that was pulled. The dependency was in fact listed in the package.json file for ember-cli but I don't think anyone ever noticed it until later versions.
Proof: https://github.com/stefanpenner/ember-cli/blob/ec8a6ab898599746bddbb8f72f7633c29f0ee95b/package.json#L58
I was able to resolve this issue by uninstalling node and npm completely using brew. Then, installing node.js using the package from nodejs.org. Now, my npm version is 1.4.28. Looks like the issue was caused by the newer npm 2.1.10. Not sure why brew automatically picks up the new npm.
Look in your package.json dependencies section. Looks like a typo.
I faced the same issue but it got fixed by running sudo npm install -g ember-cli

npm not working after clearing cache

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\

npm install not working

I just started learning node.js and i have installed node.js along with npm module manager.
I have created a package.json file and from the root directory iam trying to execute npm install command, instead of creating npm_modules folder it throws error like this:
C:\Users\username\Desktop\nodetest>npm install
npm WARN package.json backbone-library#0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/mongoose
npm ERR! Error: connect ETIMEDOUT
npm ERR! at errnoException (net.js:863:11)
npm ERR! at Object.afterConnect [as oncomplete] (net.js:854:19)
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 Windows_NT 6.1.7600
npm ERR! command "D:\\Program Files\\nodejs\\\\node.exe" "D:\\Program Files\\no
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Users\username\Desktop\nodetest
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
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! C:\Users\username\Desktop\nodetest\npm-debug.log
npm ERR! not ok code 0
Iam using Windows 7 OS.
Any ideas ?
Thanks,
Srinivas
This will probably solve your problem:
npm config set proxy proxy-url:port (http:\\proxy-name:port)
npm config set https-proxy proxy-url:port
It was a stuck step on my side,
the following syntax worked for me:
npm config set proxy http:/myproxyserver:port
best regards :)
You may need to use the windows "run as" command (which is equivalent to the *nix "sudo" command) in order to have the correct privileges on your machine.
This link should be helpful: https://superuser.com/questions/42537/is-there-any-sudo-command-for-windows
finally i came to know that my company laptop has proxy restrictions.Once i got the approval for proxy removal it worked.
But still ppl, who ever facing proxy issue in npm install,can try the following method.
Go to C:\Users\YourUserName
Create a file named .npmrc (no need of any prefixname just .npmrc)
Inside that file type the following
proxy = username:password#ip:port (add http:// before username)
That's all.It is perfectly working for me....
The traceroute command will usually tell you where a connection fails and would have lead you straight to the corporate proxy in this case.
Adding to the selected answer
a) "npm config set proxy proxy-url:port (http:\proxy-name:port)
b) npm config set https-proxy proxy-url:port"
make sure you add "http:\\" to your proxy name, and packages downloaded from npm use ssl so try the second option for sure.
If you are working behind a proxy, configure it:
npm config set proxy http://login:pass#host:port
Check the value of your proxy configuration:
npm config get http-proxy
Try again to get your package...

npm install gives unauthorized name or password is incorrect error

When I try to install tap using
npm install tap
I get the following error:
npm ERR! Error: unauthorized Name or password is incorrect.: tap
Here's the entire response:
npm http GET https://registry.npmjs.org/tap
npm http 401 https://registry.npmjs.org/tap
npm ERR! Error: unauthorized Name or password is incorrect.: tap
npm ERR! at RegClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:253:14)
npm ERR! at Request.init.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/main.js:120:22)
npm ERR! at Request.EventEmitter.emit (events.js:91:17)
npm ERR! at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:648:16)
npm ERR! at Request.EventEmitter.emit (events.js:115:20)
npm ERR! at IncomingMessage.Request.start.self.req.self.httpModule.request.buffer (/usr/local/lib/node_modules/npm/node_modules/request/main.js:610:14)
npm ERR! at IncomingMessage.EventEmitter.emit (events.js:115:20)
npm ERR! at IncomingMessage._emitEnd (http.js:366:10)
npm ERR! at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
npm ERR! at CleartextStream.socketOnData (http.js:1366:20)
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 Linux 3.2.0-31-generic-pae
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "tap"
npm ERR! cwd /home/thaddeus
npm ERR! node -v v0.8.8
npm ERR! npm -v 1.1.59
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/thaddeus/npm-debug.log
npm ERR! not ok code 0
Found the answer.
Remove .npmrc from my home directory and it works!
Thanks to mcollina https://github.com/mcollina at https://github.com/isaacs/npm/issues/2778
1.>Go to your this location
C:\Users\{your user name or ID}
2.> open .npmrc & Remove all content from .npmrc file.
3.>reopen your new command prompt
4.>again run the code , will work.
I was also having this problem. Mine has arised because I have changed my password in npmjs.org. So, try Login in npm from terminal again with your new password and then install any module. It worked for me.
You might have _auth entry configured in the .npmrc config file ($HOME/.npmrc). Just delete the entry if you are using the public registry as it's not needed. If you're using a private npm registry you should check with your admin that that's the correct auth key for you to access the registry.
I would not recommend just deleting the whole file (.npmrc) as the file might contain important configurations for your npm to work correctly. i.e.: proxy config.
Removing package-lock.json and node_modules did the trick in my case.
Also you can use
npm cache clean
i tried
npm cache clean
but it didn't work. I didn't see .npmrc in my directory. I killed my bash shell (terminal on mac) and brought up a new one and that seemed to do the trick. Not sure if it was the bash refresh or the npm cache clean or a combination of the two.
npm cache verify
is what you need
If you have changed your system LAN password, run npm login and provide your new password.
Once the login is successful, you will not get error while doing npm install.
I had a an odd issue where I got the credentials error and it was because npm login had cached bad credentials and then npm logout didn't clear the credentials (as evidenced by "npm login" always showing my default details).
NPM stores your login under the globals NPM_CONFIG_EMAIL and NPM_CONFIG__AUTH. If you do "npm config ls -la" and see email under "environment configs" you may have the same issue I had (where npm logout didn't work).
Unset the globals NPM_CONFIG__AUTH and NPM_CONFIG_EMAIL and then npm login again and it should work.
(in terminal it's just "unset NPM_CONFIG__AUTH")
For me I needed to create a account in npm site, after that sing in via terminal into npm using npm login, remove the .npmrc file from your /home folder and after that try npm install again in your project folder
In our case, our NPM repository is actually managed by our company, so our value for "registry=xxx" inside my global .npmrc file was different in our case. Verify with your company if you guys handle your NPM registries differently then using the npm site itself.

Resources