如何在不指定完整 node_modules 路径的情况下从 npm 包中获取替代 js 文件
How to require an alternative js file from a npm package without specifiying full node_modules path
我正在使用 ES2016 导入语法从 npm 模块(通过 Webpack)加载 select2 库:
import 'select2';
这工作正常并从 node_modules 目录加载以下文件。
node_modules/select2/dist/js/select2.js
现在在那个目录中他们有一个完整版本的库,它有一些我需要的额外功能,它叫做:
node_modules/select2/dist/js/select2.full.js
有没有办法在不提供 node_modules 文件夹的完整相对路径的情况下导入它?
我试过了:
import 'select2.full'
但运气不好。
试试这个:
import 'select2/dist/js/select2.full.js'
我认为这是你能得到的最好的。
我正在使用 ES2016 导入语法从 npm 模块(通过 Webpack)加载 select2 库:
import 'select2';
这工作正常并从 node_modules 目录加载以下文件。
node_modules/select2/dist/js/select2.js
现在在那个目录中他们有一个完整版本的库,它有一些我需要的额外功能,它叫做:
node_modules/select2/dist/js/select2.full.js
有没有办法在不提供 node_modules 文件夹的完整相对路径的情况下导入它?
我试过了:
import 'select2.full'
但运气不好。
试试这个:
import 'select2/dist/js/select2.full.js'
我认为这是你能得到的最好的。