Node.js,NPM,代理和node_modules [英] Node.js, NPM, proxy and node_modules

查看:126
本文介绍了Node.js,NPM,代理和node_modules的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装节点软件包,但是我的网络不允许我连接.我得到了标准,

I am trying to install node packages but my network won't let me connect. I get the standard,

npm ERR! network getaddrinfo ENOTFOUND

我了解这是因为我在公司网络中.但是,我对代理服务器并不十分熟悉,据我所知,我无法访问代理服务器.我不确定如何才能使用NPM.对此,任何有帮助和相关的想法都会受到欢迎!

I understand that this is because I am on a corporate network. However, I'm not very familiar with proxies and as far as I am aware, I don't have access to one so I'm not sure how I can progress with NPM. Any helpful and related thoughts about this are warmly received!

作为一种变通方法,使用其他计算机,我已通过电子邮件将所需的节点模块发送给自己.这些节点模块是使用NPM而不是在公司网络上安装的.

As a work around, using my other machine, I have emailed myself with the node modules I require. These node modules were installed using NPM while not on the corporate network.

但是,尽管事实上我已经将模块放在test_server.js文件的node_modules/目录中,但我仍然收到

However, despite the fact that I have put the modules in node_modules/ alongside my test_server.js file, I still receive,

C:\Users\JT15900\Documents\nodeServer>node test_server.js

module.js:340
    throw err;
          ^
Error: Cannot find module 'knex' ... etc.

要明确一点,test_server.js与node_modules/一起位于同一目录中.在node_modules/中,我已经放入了各种模块文件夹,例如'express'和'knex'等.

To be really clear, test_server.js sits alongside node_modules/ in the same directory. Inside node_modules/ I have put the various module folders like 'express' and 'knex', etc.

为什么我的节点脚本无法找到这些模块以及如何更正它?

Why is my node script unable to find these modules and how to I correct it?

编辑

我在超级用户处发布了帖子帮助发现我的代理设置.然后,我按照其他地方概述并在解决方案中介绍的方式配置了Node NPM代理设置.

I used a post over at superuser to help discover my proxy settings. I then configured Node NPM proxy settings as outlined elsewhere and presented in the solution.

推荐答案

这帮助了我如果公司网络具有代理,则可以使用以下命令在npm中对其进行设置

if the corporate network has a proxy you can set it in npm using these commands

npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080

很抱歉,如果您已经尝试过或不起作用.

Apologies if you already tried that or it doesn't work.

这篇关于Node.js,NPM,代理和node_modules的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆