[英]How to specify node_modules folder for locally referenced node module
We need to specify node_modules folder for locally referenced node module that resides in an external folder relative to the current application folder.
我们需要为本地引用的节点模块指定node_modules文件夹,该模块位于相对于当前应用程序文件夹的外部文件夹中。
We have a scenario where we are referencing an external common module's js files within another client-side app, however the same node modules being references in both are being duplicated in the final build. 我们有一个场景,其中我们在另一个客户端应用程序中引用了外部公共模块的js文件,但是在最终版本中都复制了两个相同的节点模块。 we have tried using webpack.optimize.DedupePlugin() without any success.
我们尝试使用webpack.optimize.DedupePlugin()失败。
The directory structure is as follows: 目录结构如下:
|—root |— common/node_modules |— app/node_modules
We want to specify via configuration either via npm or web pack a way for the app to resolve references from its specified path of node_modules and not to refer to any other node_modules location including the one in common module. |—root |— common/node_modules |— app/node_modules
我们想通过npm或Web pack通过配置指定一种方法,使该应用可以从其指定的node_modules路径解析引用,而不是引用任何其他node_modules位置,包括一个通用模块。 You can use npm link or just a simple symlink. 您可以使用npm链接或仅使用一个简单的符号链接。 Do something like that:
做这样的事情:
cd root/app (your app directory)
npm link ../common
OR 要么
cd root/app (your app directory)
ln -s ../common node_modules/common
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.