我有3个本地模块" web","演示"和"存储库"在3个不同的目录中。每个模块都有一个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正在寻找" myproject -..."最后一个命令都失败了。在npm注册表中,这是我得到的错误
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!)
请注意,我在运行“npm link'”时没有收到任何错误信息。在依赖目录(演示文稿和Web)上。它成功返回以下内容:
/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
答案 0 :(得分:0)
意识到我做错了什么。我忘了在“存储库”和“演示文稿”文件夹中创建一个.npmrc文件,然后执行上面提到的博客文章。
npm链接按预期工作