【问题标题】:npm link not working as expectednpm 链接未按预期工作
【发布时间】:2016-01-24 15:12:38
【问题描述】:

我在 3 个不同的目录中有 3 个本地模块“web”、“presentation”和“repository”。每个模块都有一个 package.json,其 name 属性为“myproject-web”、“myproject-presentation”和“myproject-repository”。

我正在尝试链接存储库 -> 网络和演示文稿 -> 网络。所以我尝试了这个:

cd ./presentation
npm link
cd ../repository
npm link
cd ../web
npm link myproject-presentation
npm link myproject-repository

最后两个命令都失败了,因为 NPM 在 npm 注册表中寻找“myproject-...”,这是我得到的错误

npm ERR! 404 Registry returned 404 for GET on http://registry.npmjs.org/myproject-repository
npm ERR! 404 
npm ERR! 404 'myproject-repository' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

请注意,在依赖目录(演示文稿和 Web)上运行“npm link”时我没有收到任何错误。它成功返回了以下内容:

/usr/local/lib/node_modules/myproject-presentation -> /Users/koder/projects/test/myproject-presentation

/usr/local/lib/node_modules/myproject-repository -> /Users/koder/projects/test/myproject-repository

我正在关注这个blog post as reference

已解决:请看我自己的回答:

Realised what i am doing wrong. I forgot to create a .npmrc file in "repository" and "presentation" folder step the blog post mentioned.

npm link is working as expected

【问题讨论】:

    标签: node.js npm


    【解决方案1】:

    意识到我做错了什么。我忘了在博客文章提到的“存储库”和“演示文稿”文件夹中创建一个 .npmrc 文件。

    npm 链接按预期工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-03
      • 2011-01-25
      • 2013-05-11
      • 1970-01-01
      相关资源
      最近更新 更多