Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Latest commit

 

History

History
194 lines (119 loc) · 5.42 KB

faq.md

File metadata and controls

194 lines (119 loc) · 5.42 KB

npm-faq(1) -- Frequently Asked Questions

Where can I find these docs in HTML?

https://github.com/isaacs/npm/tree/master/doc

It didn't work.

That's not really a question.

Why didn't it work?

I don't know yet.

Read the error output, and if you can't figure out what it means, do what it says and post a bug with all the information it asks for.

Where does npm put stuff?

See npm help folders

tl;dr:

  • Use the npm root command to see where modules go, and the npm bin command to see where executables go
  • Global installs are different from local installs. If you install something with the -g flag, then its executables go in npm bin -g and its modules go in npm root -g.

How do I install something everywhere?

Install it globally by tacking -g or --global to the command.

I installed something globally, but I can't require() it

Install it locally.

I don't wanna.

Check out npm link. You might like it.

No, I really want 0.x style 'everything global' style.

Ok, fine. Do this:

echo 'export NODE_PATH="'$(npm root -g)'"' >> ~/.bashrc
. ~/.bashrc
npm config set global true

This is not recommended.

Many things will not work if you do this. Make sure you read and understand npm help config and npm help global before you complain about things being broken.

When you realize what a mistake it was, do this to switch back:

npm config delete global --local

If 'npm' is an acronym, why is it never capitalized?

Contrary to the belief of many, "npm" is not in fact an abbreviation for "Node Package Manager". It is a recursive bacronymic abbreviation for "npm is not an acronym".

"NPM", however, is an acronym for the National Association of Pastoral Musicians. You can learn more about them at http://npm.org/. It is not an acronym, you see, but rather a capitonym.

In all earnestness, "npm" is named after its command-line utility, which was mostly designed to be easily typed by right-handed programmers using US QWERTY keyboard layouts, ending with the right-ring-finger in a postition to type the "-" key for flags and other command-line arguments, and is always lower-case, though it starts most sentences it is a part of.

How do I list installed packages?

npm ls

How do I search for packages?

npm search

Arguments are greps. npm search jsdom shows jsdom packages.

How do I update npm?

npm update npm -g

You can also update all outdated local packages by doing npm update without any arguments, or global packages by doing npm update -g.

Occasionally, the version of npm will progress such that the current version cannot be properly installed with the version that you have installed already. (Consider, if there is ever a bug in the update command.)

In those cases, you can do this:

curl http://npmjs.org/install.sh | sh

What is a package?

A package is:

  • a) a folder containing a program described by a package.json file
  • b) a gzipped tarball containing (a)
  • c) a url that resolves to (b)
  • d) a <name>@<version> that is published on the registry with (c)
  • e) a <name>@<tag> that points to (d)
  • f) a <name> that has a "latest" tag satisfying (e)

Even if you never publish your package, you can still get a lot of benefits of using npm if you just want to write a node program (a), and perhaps if you also want to be able to easily install it elsewhere after packing it up into a tarball (b).

How do I install node with npm?

You don't. Try one of these:

How can I use npm for development?

See npm help developers and npm help json.

You'll most likely want to npm link your development folder. That's awesomely handy.

To set up your own private registry, check out npm help registry.

Can I list a url as a dependency?

Yes. It should be a url to a gzipped tarball containing a single folder that has a package.json in its root. (See "what is a package?" above.)

OK, but can I list a git repo as a dependency?

No.

However, you can list a url as a dependency.

How do I symlink to a dev folder so I don't have to keep re-installing?

See npm help link

The package registry website. What is that exactly?

See npm help registry.

What's up with the insecure channel warnings?

Until node 0.4.10, there were problems sending big files over HTTPS. That means that publishes go over HTTP by default in those versions of node.

I forgot my password, and can't publish. How do I reset it?

Go to http://admin.npmjs.org/reset.

I get ECONNREFUSED a lot. What's up?

Either the registry is down, or node's DNS isn't able to reach out. This happens a lot if you don't follow all the steps in the Cygwin setup doc.

To check if the registry is down, open up http://registry.npmjs.org/-/short in a web browser. This will also tell you if you are just unable to access the internet for some reason.

If the registry IS down, let me know by emailing or posting an issue. We'll have someone kick it or something.

Who does npm?

npm view npm author

npm view npm contributors

I have a question or request not addressed here. Where should I put it?

Discuss it on the mailing list, or post an issue.

Why does npm hate me?

npm is not capable of hatred. It loves everyone, especially you.