having issue with dynamic import in nodemon with babel-node
See original GitHub issuehaving issue with dynamic import in nodemon with babel-node here is my package.json file my package.json
nodemon -1.17.2
:node -v8.11.2
:- Operating system/terminal environment:
- Command you ran: nodemon --exec babel-node server/server.js --ignore public/
Expected behaviour:- should compile without error
Actual behaviour:- but throwing an error that is Unexpected token import
here is problem :-
i ran my server/server.js file with command babel server/server.js
it is working fine
pic:-
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
node.js - Code spliting with dynamic imports still create big files
One possible solution to split the client code in files with a size smaller than 244Kb could be adding this entry to webpack.config.babel.js ......
Read more >babel-plugin-dynamic-import-node Code Examples - Snyk
Learn more about how to use babel-plugin-dynamic-import-node, ... Snyk Code to scan source code in minutes - no build needed - and fix...
Read more >Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
Instead change the require of index.js to a dynamic import() which is available in all CommonJS modules" occurs because a package you are...
Read more >Using ES6 syntax “import/export” in Node js with Babel
Additionally, I will be using Nodemon in this tutorial. Let's get right into it! In your terminal or console, you can run the...
Read more >ts-node err_require_esm | The AI Search Engine You Control
ERR_REQUIRE_ESM - TypeScript + nodemon + ts-node + node-fetch ... babel.config.ts ... to a dynamic import() which is available in all CommonJS modules....
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 Free
Top 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
Oh I’m sorry, it looks like you’d need to enable https://www.npmjs.com/package/babel-plugin-dynamic-import-node
The
syntax-dynamic-import
is just so Babel doesn’t throw a parse error, if you want to transform it into something that works on Node, you need a transform to do that.it works thanks @loganfsmyth . so here is some information about dynamic import in server side rendering with react and express. dynamic import already supports by webpack which bundles up the all the react application. but if you are using server side rendering which means compile the whole react application in server side and then send html string to the client , then babel wont understand the syntax import (‘./yourFile.js’). to make it work you need to use this https://www.npmjs.com/package/babel-plugin-dynamic-import-node plugin for node support. and you must use stage-3 preset. my babelrc config { “presets”: [“es2015”,“stage-2”,“stage-3”,“react”], “plugins”: [“dynamic-import-node”] }