简体   繁体   English

带有嵌套node_modules的项目的行为如何?

[英]How does project with nested node_modules behave?

We are trying to separate our project into "sub modules" within single repo, but keep things like webpack, express server global, so assume structure like this 我们正在尝试将我们的项目分成单个仓库中的“子模块”,但要保持webpack,express server等全局性,因此采用这样的结构

package.json
server.js
index.js
node_modules/
public/
  index.html
  dashboard.js
  onboarding.js
dashboard/
  index.js
  package.json
  node_modules/
  components/
  assets/
onboarding/
  index.js
  package.json
  node_modules/
  ...

idea here is to keep build / routing / server logic at root lvl and separate modules like dashboard and onboarding into their separate folders and allow them to use their own node modules. 这里的想法是将构建/路由/服务器逻辑保留在根lvl处,并将单独的模块(如dashboardonboarding保留在各自的文件夹中,并允许他们使用自己的节点模块。

Will this work? 这样行吗? Will node modules be included correctly? 是否正确包含节点模块?

webpack will build assets to public/ folder, with some vendor assets and several entry points ie all index.js files webpack会将资产构建到public/文件夹,其中包含一些供应商资产和几个入口点,即所有index.js文件

What you are proposing will work fine and compile as you expect. 您提出的建议可以正常工作,并且可以按预期进行编译。 NodeJS will initially look for modules included in your modules 'node_modules' sub-directory and then work up the ladder. 首先,NodeJS将寻找模块“ node_modules”子目录中包含的模块,然后逐步完善。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 node_modules 中的新组件导入到项目中? - How an I import new components from node_modules into the project? 当项目中不包含node_modules文件夹时,Node.js在哪里搜索模块? - Where does Node.js search for modules when no node_modules folder included in project? script标记如何解析node_modules的路径? - How does script tag resolves path to node_modules? 更改特定于项目的node_modules路径 - Change node_modules path specific to project VSCode 不会忽略 node_modules 的建议 - VSCode does not ignore node_modules on suggestions Webpack 正在从我机器的全局“node_modules”导入模块。 如何让它只从我的项目的 `node_modules` 导入? - Webpack is importing modules from my machine's global `node_modules`. How do I get it to only import from my project's `node_modules`? 如何使Webpack在位于项目文件夹外部的js脚本中使用项目的“ node_modules”? - How to make Webpack use project's “node_modules” in js scripts located outside the project folder? 转译 ES6 嵌套的 node_modules 依赖的顶级 node_modules 依赖 - Transpile ES6 nested node_modules dependency of the top level node_modules dependency 在项目或这些目录 node_modules/ethereumjs-wallet/node_modules 中找不到加密 - crypto could not be found within the project or in these directories node_modules/ethereumjs-wallet/node_modules "Babel 不会从 'node_modules' 转译导入的模块" - Babel does not transpile imported modules from 'node_modules'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM