简体   繁体   中英

Installing to a different directory than package.json?

I set up a folder hierarchy exactly how I'd like it.
All my config files are in one folder ( most importantly package.json ). I want to install this package.json configuration to a different path namely ...

c\\install\\grunt

If I do

npm install -g , this will install it to my user account space - some_long_path

If I do

npm install it will install it to the current directory.

If I do

npm install --prefix correct_path

it will install it to that correct path. Yea! II thought I had it, but now it also expects the package.json file to be there.

It sets up the etc directory and then throws an error.

I don't want to do anything crazy like change the name of the node_modules folder, I just need my package.json file separate from the install files.

I realize this is a bit un-conventional but its just how I want to do it.

Is this possible? Yes or No where is the documentation?

Thank you

The solution I found did not reside in the npm documentation or grunt doucmentation. What worked was simply using a hard link.

This makes a file appear to be anywhere. This way you only need to edit it in one place, and when there are strict folder hierarchies that are seemingly enforced you can just place the hard link there.

This allowed me to design a folder hierarchy that met my needs, in this case separating configuration files from actual install files.

ln from_file to_file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM