node.js 手动安装 NPM 包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11605621/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:03:47  来源:igfitidea点击:

Manually installing NPM packages

node.jsinstallexpress

提问by paynestrike

I used the node windows installer v0.8.3 to install nodejs. When I try to install express like this:

我使用 node windows installer v0.8.3 来安装 nodejs。当我尝试像这样安装 express 时:

npm install express

It's not working. I think that is because my company is using a proxy, so I downloaded express from github https://github.com/visionmedia/express, but I don't know how to install.

它不起作用。我想是因为我公司用的是代理,所以我从github https://github.com/visionmedia/express下载了express ,但是不知道怎么安装。

I unzip the file and put them in F/express/. Please help me? I'm on Windows

我解压缩文件并将它们放在 F/express/ 中。请帮我?我在 Windows 上

When I try to install from F:/express/ using the following commands

当我尝试使用以下命令从 F:/express/ 安装时

cd F:/express
npm install ./express

or

或者

npm install .

I get the following error:

我收到以下错误:

error: connect ETIMEDOUT
at errnoException (net.js:776:11)
at Object.afterConnect [as oncomplete] (net.js:767:19)

And when when I try to do

当我尝试做

npm install F:/express

It shows

表明

[email protected] prepublish F:/express/
npm prune

followed by lots of http get messages and then the same error

随后是大量的 http get 消息,然后是相同的错误

采纳答案by Max Nanasy

It would probably be most convenient long-term to configure NPM to use the aforementioned proxy through one of the following methods (In the following, replace $PROXY with your proxy in the form $PROTOCOL://$DOMAIN:$PORT (e.g. http://proxy.server:80))

从长远来看,通过以下方法之一配置 NPM 以使用上述代理可能是最方便的(在下文中,将 $PROXY 替换为您的代理,格式为 $PROTOCOL://$DOMAIN:$PORT(例如http ://proxy.server:80))

A. Set the environment variables http_proxy and https_proxy to $PROXY

A. 将环境变量 http_proxy 和 https_proxy 设置为 $PROXY

B.

B.

npm set proxy $PROXY
npm set https-proxy $PROXY

回答by Alfred

express itself has a lot of dependencies which I believe npm also tries to retrieve if you issue npm install. I think you should just configure proxy properly => http://jjasonclark.com/how-to-setup-node-behind-web-proxy?

express 本身有很多依赖项,我相信如果您发出npm install. 我认为您应该正确配置代理 => http://jjasonclark.com/how-to-setup-node-behind-web-proxy

回答by Peter Kwan

If you have trouble getting packages because of a proxy or other internet connection problem then set up the project on another machine. Then copy the project over to your target. It will have all the files that you need.

如果由于代理或其他 Internet 连接问题而无法获取包,请在另一台计算机上设置项目。然后将项目复制到您的目标。它将包含您需要的所有文件。

回答by Max Nanasy

Try npm install .\express(assuming the express folder is in the current folder).

尝试npm install .\express(假设 express 文件夹在当前文件夹中)。

The problem is that expressin npm install expressis parsed as a package name, while .\expressin npm install .\expressis parsed as a folder name.

问题是expressinnpm install express被解析为包名,而.\expressinnpm install .\express被解析为文件夹名。

回答by philipvr

You will want to run npm install .from within your F:/express/folder (or npm install -g .for a global install).

您将希望npm install .从您的F:/express/文件夹中运行(或npm install -g .全局安装)。

It looks like you downloaded beta version (3.0.0beta7). Try installing the latest stable version (2.5.11):

看起来您下载了测试版(3.0.0beta7)。尝试安装最新的稳定版本 (2.5.11):

npm install https://github.com/visionmedia/express/tarball/2.5.11