NodeJS:如何在不同的目录中使用 package.json 和 node_modules
NodeJS: how to use package.json and node_modules in different directories
我有一个使用文件结构的应用程序
package.json
src/main/
- webapp
- java (containing my API)
我的 API 受到限制,因此它只能从 src/main/webapp
中发送文件,因此我需要将我的 node_modules
安装到该文件夹中。
如果我 运行 npm install
我得到以下结果:
package.json
node_modules/
src/main/
- webapp
- java (containing my API)
有什么方法可以更改它,使其默认安装在以下结构中?
package.json
src/main/
- webapp
- node_modules/
- java (containing my API)
如果可能的话,我宁愿没有全局环境变量,因为我在这台机器上处理多个应用程序,我不希望它们都安装到这个应用程序 node_modules
对于上述情况,我打算安装我的 webapp 依赖项,例如 AngularJS 使用 NodeJS。事实证明,还有另一个包管理器 Bower 更适合此目的,并允许您将其 bower_components
的位置配置到您喜欢的任何位置。这解决了我的问题,我现在有以下文件结构
package.json
node_modules/
src/main/
- webapp
-bower_components
-angular (etc)
- java (containing my API)
我有一个使用文件结构的应用程序
package.json
src/main/
- webapp
- java (containing my API)
我的 API 受到限制,因此它只能从 src/main/webapp
中发送文件,因此我需要将我的 node_modules
安装到该文件夹中。
如果我 运行 npm install
我得到以下结果:
package.json
node_modules/
src/main/
- webapp
- java (containing my API)
有什么方法可以更改它,使其默认安装在以下结构中?
package.json
src/main/
- webapp
- node_modules/
- java (containing my API)
如果可能的话,我宁愿没有全局环境变量,因为我在这台机器上处理多个应用程序,我不希望它们都安装到这个应用程序 node_modules
对于上述情况,我打算安装我的 webapp 依赖项,例如 AngularJS 使用 NodeJS。事实证明,还有另一个包管理器 Bower 更适合此目的,并允许您将其 bower_components
的位置配置到您喜欢的任何位置。这解决了我的问题,我现在有以下文件结构
package.json
node_modules/
src/main/
- webapp
-bower_components
-angular (etc)
- java (containing my API)