node.js npm 本地安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6514621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install locally
提问by Alfred
In the past when I installed packages using npm(>=1.0) they would be installed locally, but not anymore.
过去,当我使用 npm(>=1.0) 安装软件包时,它们会在本地安装,但现在不会了。
My setup:
我的设置:
First I use nvmto install node.js.
My operating System:
alfred@alfred-laptop:~/node/so/6513101$ cat /etc/lsb-release DISTRIB_ID=Ubuntu<br> DISTRIB_RELEASE=10.10 DISTRIB_CODENAME=maverick DISTRIB_DESCRIPTION="Ubuntu 10.10"My node version:
alfred@alfred-laptop:~/node/so/6513101$ node -v v0.4.8My npm version:
alfred@alfred-laptop:~/node/so/6513101$ npm -v 1.0.15
我的操作系统:
alfred@alfred-laptop:~/node/so/6513101$ cat /etc/lsb-release DISTRIB_ID=Ubuntu<br> DISTRIB_RELEASE=10.10 DISTRIB_CODENAME=maverick DISTRIB_DESCRIPTION="Ubuntu 10.10"我的节点版本:
alfred@alfred-laptop:~/node/so/6513101$ node -v v0.4.8我的 npm 版本:
alfred@alfred-laptop:~/node/so/6513101$ npm -v 1.0.15
Installing random package
安装随机包
alfred@alfred-laptop:~/node/so/6513101$ npm install notifo
[email protected] ../../../node_modules/notifo
In the past it would install into the same directory but it does not install in the same directory anymore. is my npm/node.js broken or am I missing something or does npm not anymore install local packages(inside same folder => ~/node/so/6513101/node_modules) which I thought was a cool feature because I could bundleall my dependencies so that other users did not have to install npm to use my code(I still believe users should install npm because it is a great product). The bundlecommand is gone so I can't use that? Could someone please explain to me what is going on?
过去它会安装到同一目录中,但不再安装在同一目录中。我的 npm/node.js 坏了还是我遗漏了什么或者 npm 不再安装本地包(在同一个文件夹内 => ~/node/so/6513101/node_modules),我认为这是一个很酷的功能,因为我可以使用bundle我所有的依赖项,这样其他用户就不必安装npm 使用我的代码(我仍然相信用户应该安装 npm 因为它是一个很棒的产品)。该bundle命令没有了,所以我不能使用?有人可以向我解释发生了什么吗?
回答by isaacs
npm walks up the folder tree until it finds a node_modulesor a package.jsonand uses that as the root. What does npm rootprint out?
npm 沿着文件夹树向上走,直到找到 anode_modules或 apackage.json并将其用作根。什么是npm root打印出来?
If you mkdir node_modulesor create a package.json file, then it'll use the cwd.
如果您mkdir node_modules或创建一个 package.json 文件,那么它将使用 cwd。
EDIT: I won't see updates you post here. For better results, just post everything in the github issue, and let's do the support over there.
编辑:我不会看到你在这里发布的更新。为了更好的结果,只需在github issue中发布所有内容,让我们在那里做支持。

