简体   繁体   English

Webpack无法解析第三方模块

[英]Webpack unable to resolve a third-party module

I'm using compact/angular-bootstrap-lightbox in a project migrating from RequireJS to webpack, and am wondering if the error I'm getting is in my setup or the module itself. 我在从RequireJS迁移到webpack的项目中使用了compact / angular-bootstrap-lightbox ,想知道我得到的错误是在安装程序还是模块本身。

In my webpack entry point, I have: 在我的webpack入口点,我有:

require("angular");
require("angular-bootstrap-lightbox");
...

So, to attempt to satisfy those dependencies: 因此,尝试满足这些依赖关系:

  1. npm install angular
  2. npm install angular-bootstrap-lightbox
  3. webpack

Results in: 结果是:

Module not found: Error: Cannot resolve module 'angular-bootstrap-lightbox' in ...

If I comment out the angular-bootstrap-lightbox require() call, Google's AngularJS imports just fine, which makes me think the issue is with the third party module. 如果我注释掉angular-bootstrap-lightbox require()调用,那么Google的AngularJS导入就可以了,这使我认为问题出在第三方模块上。 If that is the case, what are they missing that they should add, and is there a temporary workaround? 如果是这种情况,应该增加哪些缺失,是否有临时解决方法?

angular-bootstrap-lightbox doesn't have a main file specified in package.json. angular-bootstrap-lightbox在package.json中没有指定主文件。 But there is index.js which requires the script. 但是有index.js需要脚本。 So you just need to specify it manually: 因此,您只需要手动指定它:

require("angular-bootstrap-lightbox/index.js");

You probably want to load css as well. 您可能还想加载CSS。 So specify it similar way: 因此,以类似方式指定它:

require("angular-bootstrap-lightbox/dist/angular-bootstrap-lightbox.css");

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM