简体   繁体   English

要安装到与package.json不同的目录吗?

[英]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 ). 我所有的配置文件都在一个文件夹中(最重要的是package.json)。 I want to install this package.json configuration to a different path namely ... 我想将此package.json配置安装到其他路径...

c\\install\\grunt c \\ install \\ grunt

If I do 如果我做

npm install -g , this will install it to my user account space - some_long_path npm install -g ,它将安装到我的用户帐户空间-some_long_path

If I do 如果我做

npm install it will install it to the current directory. npm install它将安装到当前目录。

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. 我以为我有它,但现在它也希望package.json文件在那里。

It sets up the etc directory and then throws an error. 它设置etc目录,然后引发错误。

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. 我不想做任何疯狂的事情,例如更改node_modules文件夹的名称,我只需要将package.json文件与安装文件分开即可。

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. 我发现的解决方案不存在于npm文档或grunt文档中。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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