Monday, June 3, 2024
112
rated 0 times [  117] [ 5]  / answers: 1 / hits: 125562  / 9 Years ago, tue, january 5, 2016, 12:00:00

Is it possible to import javascript module from external url in ES6?



I tried (using babel-node):



import mymodule from 'http://...mysite.../myscript.js';
// Error: Cannot find module 'http://...mysite.../myscript.js'

More From » ecmascript-6

 Answers
74

2018 Update: The module loader spec is now a part of the ES Spec - what you are describing is allowed and possible with <script type=module> in browsers and with a custom --loader with Node.js as well as with Deno if you're into that.






The module loader spec and the import/export syntax are separate. So this is a property of the module loader (not a part of the ES spec). If you use a module loader that supports plugins like SystemJS.


[#63840] Saturday, January 2, 2016, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pranav

Total Points: 693
Total Questions: 119
Total Answers: 119

Location: Greenland
Member since Fri, Jul 31, 2020
4 Years ago
pranav questions
Thu, Feb 10, 22, 00:00, 2 Years ago
Tue, Dec 28, 21, 00:00, 2 Years ago
Mon, Sep 6, 21, 00:00, 3 Years ago
Mon, Mar 8, 21, 00:00, 3 Years ago
;