[英]How to require an alternative js file from a npm package without specifiying full node_modules path
I am using the ES2016 import syntax to load the select2 libray from an npm module (via Webpack): 我使用ES2016导入语法从npm模块加载select2 libray(通过Webpack):
import 'select2';
This works fine and loads the following file from the node_modules directory. 这很好用,并从node_modules目录加载以下文件。
node_modules/select2/dist/js/select2.js node_modules /选择2 /距离/ JS / select2.js
Now within that directory they have a full version of the library which has some extra functionality I need, it is called: 现在在该目录中,他们有一个完整版本的库,它有一些我需要的额外功能,它被称为:
node_modules/select2/dist/js/select2.full.js node_modules /选择2 /距离/ JS / select2.full.js
Is there a way to import this without providing the full relative path to my node_modules folder? 有没有办法导入这个而不提供我的node_modules文件夹的完整相对路径?
I tried: 我试过了:
import 'select2.full'
but no luck. 但没有运气。
Try this: 试试这个:
import 'select2/dist/js/select2.full.js'
I think this is the best you are going to get. 我认为这是你将获得的最好成绩。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.