NPM: After "npm link" module is not found

node.js, npm

Solution

The problem was that the `main` property of `package.json` was pointing to a non-existing file. It seems that the problem can happen due to multiple reasons so be sure to take a look at other answers.

Problem

I'm developing two modules for NodeJS, first one named `aligator` and second one `aligator-methods`. Second one depends on first one to work. I'm developing these two modules at the same time and I want to global link `aligator` so I can use it like it is on npm registry and I just installed it globally. To do this NPM documentation says that I need to use `npm link` but it's not working. File `package.json` of module `aligator`: ``` { "name": "aligator", "version": "0.0.1", "description": "", "main": "index.js", "private": true, "directories": { "doc": "docs", "example": "examples", "test": "spec" }, "scripts": { "test": "gulp jasmine" }, "license": "MIT", "devDependencies": { "gulp": "^3.6.2", "gulp-jasmine": "^0.2.0", "gulp-jshint": "^1.6.1", "gulp-rename": "^1.2.0", "jasmine-node": "^1.14.3" }, "dependencies": { "bluebird": "^1.2.4", "lodash": "^2.4.1", "mathjs": "^0.22.0" } } ``` File `package.json` of module `aligator-methods`: ``` { "name": "aligator-methods", "version": "0.0.1", "description": "", "main": "index.js", "private": true, "directories": { "doc": "docs", "example": "examples", "test": "jasmine" }, "scripts": { "test": "gulp jasmine" }, "author": "", "license": "MIT", "devDependencies": { "gulp": "^3.6.2", "gulp-jasmine": "^0.2.0", "gulp-jshint": "^1.6.1", "gulp-rename": "^1.2.0", "jasmine-node": "^1.14.3" }, "dependencies": { "lodash": "^2.4.1", "mathjs": "^0.22.0", "aligator": "^0.0.1" } } ``` First of all I linked the module globally: ``` $ cd ~/aligator $ npm link /usr/local/lib/node_modules/aligator -> /Users/roc/aligator ``` This if I'm not mistaken has created a global reference of my module `aligator` and now I can use this module from everywhere I want in the computer. Then I went to the other module and tried to install the dependency but it gave me this output: ``` $ cd ~/aligator-methods $ npm install npm ERR! 404 404 Not Found: aligator npm ERR! 404 npm ERR! 404 'aligator' is not in the npm registry. npm ERR! 404 You should bug the author to publish it npm ERR! 404 It was specified as a dependency of 'aligator-methods' npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, or http url, or git url. npm ERR! System Darwin 13.2.0 npm ERR! command "node" "/usr/local/bin/npm" "install" npm ERR! cwd /Users/roc/aligator-methods npm ERR! node -v v0.10.28 npm ERR! npm -v 1.4.16 npm ERR! code E404 npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/roc/aligator-methods/npm-debug.log npm ERR! not ok code 0 ``` I even tried to link it directly with: ``` $ cd ~/aligator-methods $ npm link aligator /Users/roc/aligator-methods/node_modules/aligator -> /usr/local/lib/node_modules/aligator -> /Users/roc/aligator ``` But it didn't work either. Any thoughts on what it is that could be happening? I read somewhere that maybe it had something to do with my installation of node and npm because it was made by Homebrew and so sometimes I need to use `sudo`, it seemed unlikely but I tried what they proposed and It didn't work either.

Original source

Related problems