问题
I'm doing some work on a command line interface, and to test it from the root of the project I do:
npm i -g
After this I can test the command on various projects.
IIUC running npm i -g
creates global links that are executable, but the actual files being run are the original project files?
Running:
ole@mki:~/SuperflyCSS/cli$ npm list -g | grep superfly
├─┬ @superflycss/cli@4.1.2 -> /home/ole/SuperflyCSS/cli
│ ├─┬ @superflycss/pli@3.0.0
Seems to indicate that this is the case.
I just want to triple check because I'm getting an odd scenario where it looks as if NPM is making a copy.
This issue is related to this issue.
回答1:
Globally installed modules are placed in "/usr/local/lib/node_modules" (or its equivalent on your system, which you can find by running "npm list -g").
As for the binaries that are globally installed, symbolic links to them are placed in "/usr/local/bin", but you can find out where they are on your system by using "npm bin -g".
For example, browserify installed to "/usr/local/lib/node_modules/browserify", and has a "/bin/cmd.js" file that is linked as:"/usr/local/bin/browserify->/usr/local/lib/node_modules/browserify/bin/cmd.js".
来源:https://stackoverflow.com/questions/54270592/does-a-global-install-of-a-local-node-project-just-create-executable-links-back