简体   繁体   中英

ES6 javascript import external js file

I'm trying this in my ES6 javascript module:

import externalutil from 'https://externalutil.com/js/externalutil.js';

but it fails with this transpile error:

Module not found: 'https://externalutil.com/js/externalutil.js' 

The file externalutil.js is an old-fashioned javascript library that does not export anything.

Any help will be appreciated.

You cannot import URL's (as of yet). You should download the file, put it somewhere locally and reference it locally as well.

However in your case, I'd just use a <script /> tag to include it in your html and just access the window object. Converting it would be more hassle than it would be beneficial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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