I’m working on two NodeJS modules: raptor and raptor-utils. The raptor-utils module depends on raptor. I want to use raptor locally as if it were installed from npm. I followed the npm docs and used npm link, but it’s not working as expected.
I ran npm link in the raptor directory, which seemed to create a global reference. But when I try to install dependencies in raptor-utils, I get a 404 error saying raptor isn’t in the npm registry.
I also tried npm link raptor in the raptor-utils directory, but that didn’t solve the problem either.
Here’s a simplified version of my package.json for raptor-utils:
{
"name": "raptor-utils",
"version": "0.1.0",
"dependencies": {
"raptor": "^0.1.0",
"underscore": "^1.13.1"
}
}
What could be causing this issue? Is it related to my Node or npm installation? I’m using macOS and installed Node via Homebrew. Any help would be appreciated!
I’ve encountered similar challenges with local module dependencies. One approach that’s worked for me is using the ‘file:’ protocol in your package.json instead of npm link. Try modifying your raptor-utils package.json like this:
{
"dependencies": {
"raptor": "file:../raptor",
"underscore": "^1.13.1"
}
}
This tells npm to use the local directory for raptor. Make sure the path is correct relative to raptor-utils. Then run npm install in the raptor-utils directory. This method often resolves issues with local dependencies more reliably than npm link in my experience. Let me know if this works for you.
I’ve run into similar issues with npm link before, and it can be tricky to get right. One thing that helped me was to make sure I was using the correct path when linking.
Instead of just npm link raptor, try using the full path to your local raptor module. Something like:
npm link /path/to/your/raptor/directory
This ensures npm knows exactly where to find your local module.
Also, double-check that the version in your raptor’s package.json matches what you’ve specified in raptor-utils’ dependencies. If they don’t match, npm might still try to fetch from the registry.
Lastly, clearing npm’s cache (npm cache clean --force) and removing node_modules before trying again sometimes helps resolve stubborn linking issues. Hope this helps!
hey mate, i’ve dealt with npm link headaches too. have u tried running npm link in the raptor dir, then npm link raptor in raptor-utils? also, make sure ur package.json in raptor has the right name field. sometimes npm gets confused if names don’t match up. good luck!