【问题标题】:Using npm behind firewall using Visual Studio 2015使用 Visual Studio 2015 在防火墙后使用 npm
【发布时间】:2019-09-11 19:59:32
【问题描述】:

我尝试利用 Visual Studio 2015 中的新 npm 支持,但遇到了一些问题。我位于公司防火墙后面。

我尝试从 package.json 文件中添加“grunt”,并且可以看到与 npm 相关的输出。

npm http GET https://registry.npmjs.org/grunt
npm http GET https://registry.npmjs.org/grunt-bower-task
npm http GET https://registry.npmjs.org/grunt-contrib-cssmin
npm http GET https://registry.npmjs.org/grunt-bower-task
npm http GET https://registry.npmjs.org/grunt-contrib-cssmin
npm http GET https://registry.npmjs.org/grunt
npm http GET https://registry.npmjs.org/grunt
npm http GET https://registry.npmjs.org/grunt-bower-task
npm http GET https://registry.npmjs.org/grunt-contrib-cssmin
npm ERR! Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR!     at SecurePair.<anonymous> (tls.js:1367:32)
npm ERR!     at SecurePair.emit (events.js:92:17)
npm ERR!     at SecurePair.maybeInitFinished (tls.js:979:10)
npm ERR!     at CleartextStream.read [as _read] (tls.js:471:13)
npm ERR!     at CleartextStream.Readable.read (_stream_readable.js:340:10)
npm ERR!     at EncryptedStream.write [as _write] (tls.js:368:25)
npm ERR!     at doWrite (_stream_writable.js:225:10)
npm ERR!     at writeOrBuffer (_stream_writable.js:215:5)
npm ERR!     at EncryptedStream.Writable.write (_stream_writable.js:182:11)
npm ERR!     at write (_stream_readable.js:601:24)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External\\\\node\\node" "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Data\Develop\Playground\WebBasics2
npm ERR! node -v v0.10.31
npm ERR! npm -v 1.4.9
npm

我看过一些帖子,您可以将节点配置为忽略 SSL,但不知道如何在 Visual Studio 2015 中执行此操作。

请帮忙 此致, 托马斯

【问题讨论】:

    标签: node.js npm visual-studio-2015


    【解决方案1】:

    以下步骤适用于 VS 2015

    1- 以 Administrator

    身份运行命令提示符

    2- 转到 Path of External tools 对于 VS 2015,在你的情况下它是“ C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Editors

    3- npm 配置集 ca=""

    4- npm config set strict-ssl false

    5- npm install npm -g --ca=null

    Visual Studio 2017 Professional请查看 Jignesh Hirpara 提供的 cmets

    【讨论】:

    • 从更新 3 开始,外部工具的位置是 C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External
    • 对于 VS-2017 使用路径 C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\Web Tools\Editors
    【解决方案2】:

    就我而言,上述解决方案不起作用。它在更新 .npmrc 文件后以及在 Fiddler 的帮助下运行 npm 时工作。以下是对我有用的步骤:

    • 安装 npm 后,更新位于 C:\Users\'username' 目录下的 .npmrc 文件:

    registry=http://registry.npmjs.org

    代理=http://127.0.0.1:8888

    https-proxy=http://127.0.0.1:8888

    http-proxy=http://127.0.0.1:8888

    严格-ssl=false

    • 打开 Fiddler,在“规则”选项卡下选择“授权验证”。别忘了 Fiddler 监听 8888 端口
    • 打开 Fiddler 后,npm 命令在 Visual Studio 中应该可以正常工作

    这应该可以在公司防火墙后使用,并使用域加入系统。

    【讨论】:

    • 这对我有用。我相信这是因为我在使用 npm 不支持的NTLM authentication 的公司代理背后工作。因此需要通过支持它的本地提琴手代理进行路由 - 真正的痛苦。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-16
    相关资源
    最近更新 更多