如何更改package.json输出位置

是否有一个package.json选项来指定node_modules目录的相对位置?

对于我的应用程序,我有一个如下所示的目录结构。

当前目录结构

root/ ---/client -------/(client code) ---/server ------/package.json* (sibling of node_modules) ------/node_modules* ------/server.js 

我想将grunt任务添加到项目的根目录(因为它们将应用于客户端代码和服务器代码)。 Gruntfile.js需要是package.json的兄弟 。

我想将package.json移到根目录,但是我也想把node_modules保存在服务器目录下。 在package.json中有一个选项来做到这一点吗?

我想要得到的目录结构如下所示。

首选目录结构

 root/ ---/package.json* (not a sibling of node_modules) ---/Gruntfile.js ---/client -------/(client code) ---/server ------/node_modules* 

像下面这样的选项是最受欢迎的(在npm文档中似乎没有这样的选项)

假设的package.json

 { "output_dir": "server/node_modules", // Something like this "dependencies": { ... }, "devDependencies": { ... } } 

您可以在CLI上使用前缀选项来执行此操作。

 npm install express --prefix ./server/node_modules 

不知道类似的选项是否通过package.json存在