Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

E404 when trying to link local npm module

Tags:

node.js

npm

I am getting a 404 error when trying to link a local module with npm following the docs

Inside the local module directory seems like it creates a global link correctly:

$ npm link
/usr/local/lib/node_modules/my-module-name -> /Users/XXX/my-module-directory/my-module-name

But when just after that I try to link this from other project directory i get an 404 error:

$ npm link my-module-name
npm ERR! code E404
npm ERR! 404 Not Found: my-module-name@latest

I've tried to unlink the module and link again or change versions but it doesn't work.

Here is full log:

0 info it worked if it ends with ok
1 verbose cli [ '/Users/XXX/.nvm/versions/node/v8.2.1/bin/node',
1 verbose cli   '/Users/XXX/.nvm/versions/node/v8.2.1/bin/npm',
1 verbose cli   'link',
1 verbose cli   'my-module-name' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 7d82e8d8dc1bdc83
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 404 https://registry.npmjs.org/my-module-name 2304ms
8 silly fetchPackageMetaData error for my-module-name@latest 404 Not Found: my-module-name@latest
9 verbose stack Error: 404 Not Found: my-module-name@latest
9 verbose stack     at fetch.then.res (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/fetch.js:41:19)
9 verbose stack     at tryCatcher (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
9 verbose stack     at Promise._settlePromiseFromHandler (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
9 verbose stack     at Promise._settlePromise (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
9 verbose stack     at Promise._settlePromise0 (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
9 verbose stack     at Promise._settlePromises (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
9 verbose stack     at Async._drainQueue (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
9 verbose stack     at Async._drainQueues (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
9 verbose stack     at Immediate.Async.drainQueues (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
9 verbose stack     at runCallback (timers.js:781:20)
9 verbose stack     at tryOnImmediate (timers.js:743:5)
9 verbose stack     at processImmediate [as _immediateCallback] (timers.js:714:5)
10 verbose cwd /Users/XXX/my-project-directory
11 verbose Darwin 16.6.0
12 verbose argv "/Users/XXX/.nvm/versions/node/v8.2.1/bin/node" "/Users/XXX/.nvm/versions/node/v8.2.1/bin/npm" "link" "my-module-name"
13 verbose node v8.2.1
14 verbose npm  v5.3.0
15 error code E404
16 error 404 Not Found: my-module-name@latest
17 verbose exit [ 1, true ]
like image 503
Grzegorz Pawlik Avatar asked Oct 18 '22 07:10

Grzegorz Pawlik


1 Answers

You're using an NVM-installed version of Node.js to run npm link my-module-name, but you didn't run npm link (in your module's directory) using that same version.

The initial link is created in /usr/local/lib/node_modules, but when you use NVM, each Node.js version gets their own "lib" directory, in your example /Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules, which is a different directory.

like image 90
robertklep Avatar answered Oct 21 '22 02:10

robertklep