是否有 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 docs中似乎没有这样的选项)
假设的 package.json
{
"output_dir": "server/node_modules", // Something like this
"dependencies": { ... },
"devDependencies": { ... }
}