npm并不总是使用自定义注册表

时间:2016-01-06 12:18:14

标签: npm

我有一个CI版本,可以下载NPM并运行构建。我们有一个nexus安装,我们用于maven构建,所以我也想用它来缓存NPM模块。

我将它放在构建用户主目录中名为.npmrc的文件中:

registry=http://localhost:8081/nexus/content/repositories/npmjs/

grunt构建开始使用自定义注册表,但有时使用官方注册表。有没有办法强制NPM始终使用我的自定义注册表?这是构建输出的片段:

[INFO] npm http GET http://localhost:8081/nexus/content/repositories/npmjs/dateformat/-/dateformat-1.0.2-1.2.3.tgz
[INFO] npm http 200 http://localhost:8081/nexus/content/repositories/npmjs/dateformat/-/dateformat-1.0.2-1.2.3.tgz
[INFO] npm http GET http://localhost:8081/nexus/content/repositories/npmjs/ansi-regex
[INFO] npm http 200 http://localhost:8081/nexus/content/repositories/npmjs/ansi-regex
[INFO] npm http GET http://localhost:8081/nexus/content/repositories/npmjs/wrench
[INFO] npm http 200 http://localhost:8081/nexus/content/repositories/npmjs/wrench
[INFO] npm http GET http://localhost:8081/nexus/content/repositories/npmjs/inherits
[INFO] npm http GET http://localhost:8081/nexus/content/repositories/npmjs/graceful-fs
[INFO] npm http GET https://registry.npmjs.org/semver/-/semver-4.3.6.tgz
[INFO] npm http GET https://registry.npmjs.org/uglify-js/-/uglify-js-2.4.23.tgz
[INFO] npm http GET https://registry.npmjs.org/closure-compiler/-/closure-compiler-0.2.6.tgz
[INFO] npm http GET http://localhost:8081/nexus/content/repositories/npmjs/lodash-compat/3.10.1
[INFO] npm http 200 http://localhost:8081/nexus/content/repositories/npmjs/inherits
[INFO] npm http GET https://registry.npmjs.org/glob/-/glob-5.0.12.tgz
[INFO] npm http 200 http://localhost:8081/nexus/content/repositories/npmjs/graceful-fs
[INFO] npm http 200 http://localhost:8081/nexus/content/repositories/npmjs/lodash-compat/3.10.1

1 个答案:

答案 0 :(得分:1)

您可以尝试npm-proxy-cache,它可以作为本地代理,看起来像您想要的。

或者,如果您要使用本地注册表,则可以尝试verdaccio,它很棒。