【发布时间】: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
【问题讨论】: