npm link deleting modules #2996

Closed
solidgoldpig opened this Issue Dec 12, 2012 · 8 comments

Comments

Projects
None yet
3 participants

(Apologies for positing this here rather than the google group, but I can't join it and so can't post there)

Running npm link inside a module package is deleting it rather than
creating a link to it. I've tested with a few modules and the
behaviour is the same.

% npm -v
1.1.66

% node -v
v0.8.15

% pwd
/usr/local/lib/node_modules

% sudo npm install less -g
npm http GET https://registry.npmjs.org/less
npm http 200 https://registry.npmjs.org/less
npm http GET https://registry.npmjs.org/less/-/less-1.3.1.tgz
npm http 200 https://registry.npmjs.org/less/-/less-1.3.1.tgz
/usr/local/bin/lessc -> /usr/local/lib/node_modules/less/bin/lessc
less@1.3.1 /usr/local/lib/node_modules/less

% ls less
CHANGELOG.md Makefile benchmark build lib test
LICENSE README.md bin dist package.json

% cd less/

% sudo npm link
npm ERR! Error: ENOENT, stat '/usr/local/lib/node_modules/less'
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! npm-@googlegroups.com

npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "link"
npm ERR! Error: ENOENT, no such file or directory
npm ERR! at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:235:28)
npm ERR! at cb (/usr/local/lib/node_modules/npm/lib/link.js:121:14)
npm ERR! at /usr/local/lib/node_modules/npm/lib/link.js:128:24
npm ERR! at /usr/local/lib/node_modules/npm/node_modules/slide/lib/chain.js:16:22
npm ERR! at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! npm-@googlegroups.com

npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "link"

/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:235
log.error("cwd", process.cwd())
^
Error: ENOENT, no such file or directory
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:235:28)
at process.EventEmitter.emit (events.js:126:20)

% ls

% cd ..

% pwd
/usr/local/lib/node_modules

% ls less
ls: less: No such file or directory

Member

edef1c commented Dec 12, 2012

npm link without any further arguments will place a symlink in your global node_modules directory, for when you have a module in your homedir or something and you want to make it global. This'll overwrite an existing global module of the same name.
npm link modulename will place a symlink in the closest (local) node_modules to the package in the global node_modules, for when you have a global module you want to reuse in a project.
As far as I can tell, this is correct behaviour, though a warning might be in order for this particular case.

edef1c was assigned Dec 12, 2012

So if you have installed a module globally (with the -g flag), you shouldn't need to npm link at all?

Weirdness then, since I can't just require my modules installed in the global node_modules but have to provide a path to them.

Anyhow, that is beyond the scope and purpose of this github page...

Member

edef1c commented Dec 13, 2012

That's correct behaviour.
npm FAQ: I installed something globally, but I can't require() it
If you want to use a globally installed module in a program, do npm link modulename in the directory of the program itself.

edef1c closed this Dec 13, 2012

Member

edef1c commented Dec 13, 2012

whoops, accidentally closed it. the lack of warning when overwriting with a link is an issue and I'll work on that.

edef1c reopened this Dec 13, 2012

Member

timoxley commented Jan 7, 2014

@solidgoldpig @nathan7 do you still feel this is an issue?

I've completely forgotten what I was trying to do there - but I presume Nathan's point still holds?

Member

timoxley commented Jan 7, 2014

@solidgoldpig it does, though warrants a new issue really. If you're no longer bothered perhaps just close this.

#4430

Closed, as per @timoxley 's suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment