How to import in NodeJS?
See original GitHub issueI can’t seem to manage to import it in NodeJS using import x from 'y'
. There’s nothing in the docs.
If I do: import { iframeResizer } from 'iframe-resizer'
I get the error that the element is not exported.
And if I just import x
I get the error that there is no default export
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Getting started with Node.js modules: require, exports, imports ...
Imports. Starting with version 8.5.0+, Node.js supports ES modules natively with a feature flag and new file extension *.mjs ...
Read more >How to use an ES6 import in Node.js? - GeeksforGeeks
Introduction to ES6 import: The import statement is used to import modules that are exported by some other module. A module is a...
Read more >import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >ECMAScript modules | Node.js v19.3.0 Documentation
An import statement can reference an ES module or a CommonJS module. import statements are permitted only in ES modules, but dynamic import()...
Read more >How to use the “import” statement in Node.js | by Tirlochan Arora
If you have used other JavaScript frameworks like React or Vue.js, then you know that these frameworks use the “import” keyword for importing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tried to import the js files inside of the module directly in the parent page this way and it worked.
import 'iframe-resizer/js/iframeResizer';
also in the iframed page this way
import 'iframe-resizer/js/iframeResizer.contentWindow';
ps: There was also another problem for me while using iFrameResize method. I was using LitElement and it was rendering in the shadow DOM. Therefore sending the target as the iframe id didn’t work for me. I took the iframe ref and send it to the method.
Works perfect now, but I still don’t like the import this way.
For anyone else coming here from react side of things this worked for me. Probably not ideal but for now its a workaround