benb
benb

Reputation: 783

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):

import 'select2';

This works fine and loads the following file from the node_modules directory.

node_modules/select2/dist/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

Is there a way to import this without providing the full relative path to my node_modules folder?

I tried:

import 'select2.full'

but no luck.

Upvotes: 7

Views: 1871

Answers (1)

chapinkapa
chapinkapa

Reputation: 2653

Try this:

import 'select2/dist/js/select2.full.js'

I think this is the best you are going to get.

Upvotes: 9

Related Questions