如何将依赖项安装到包文件夹中?

How to install dependency into package folder?

我有以下文件夹结构:

- root/
     - app/
     - src/
     - node_modules/

我在 npmjs 上发布了一些包,当我输入 /root 文件夹时 npm install my_package -S 依赖项 my_package 安装在根文件夹 node_modules 中,我想将它们安装在包文件夹即 node_modules/my_package /node_modules

如何实现?

Cycles are handled using the property of node's module system that it walks up the directories looking for node_modules folders. So, at every stage, if a package is already installed in an ancestor node_modules folder, then it is not installed at the current location.

-npm docs