Is it possible to specify a target directory when running npm install <package>
?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- Failed at the electron@1.8.2 postinstall script
- How to reimport module with ES6 import
- Webpack getting started, import error
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
- Get file created date in node
You can use the
--prefix
option:The package(s) will then be installed in
./install/here/node_modules
. Themkdir
is needed since npm might otherwise choose an already existingnode_modules
directory higher up in the hierarchy. (See npm documentation on folders.)As of npm version 3.8.6, you can use
to install in the specified directory. NPM automatically creates
node_modules
folder even when anode_modules
directory already exists in the higher up hierarchy. You can also have apackage.json
in the current directory and then install it in the specified directory using--prefix
option:As of npm 6.0.0, you can use
to install the package.json in current directory to "./install/here" directory. There is one thing that I have noticed on Mac that it creates a symlink to parent folder inside the node_modules directory. But, it still works.
NOTE: NPM honours the path that you've specified through the
--prefix
option. It resolves as per npm documentation on folders, only whennpm install
is used without the--prefix
option.In the documentation it's stated: Use the prefix option together with the global option:
(Emphasis by them)
So in your root directory you could install with
and it will install the
node_modules
folder into the folder