I have a library, let's call it my_library, that I need to link it to my app. So what I've done so far is:
1. In my_library directory:
#install dependencies
npm install
cd projects/my_library
npm install
projects/my_library/node_modules is created, then build:
cd ../..
ng build
dist/my_library is created, then: cd dist/my_library
then link build to the local npm: npm link
2. Link library to app
In app directory:
npm link my_library
But npm link my_library
gives the error:
mpm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/my_library - Not found
npm ERR! 404
npm ERR! 404 'my_library@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
Does anyone know why this error is shown and how I can solve it? Thank you.
I just noticed that my library has a different node version than my app
(my_library v14.20
and my app v14.15
).
So the symlink of my_library was in /home/../.nvm/versions/node/v14.20.1/lib/node_modules/my_library
. I guess my app is not looking in the correct directory (maybe is looking in v.14.15.1
). So I used the same node version as of my_library for my app (i.e.,v14.20
) and then the problem was solved!