Cannot find module #1233
-
Describe the BugCan't import the email.jsx file from index I'm using M1 mac Tried using canary Which package is affected (leave empty if unsure)No response Link to the code that reproduces this issuehttps://github.com/liydaco/mail-server To Reproduce$npm i Expected BehaviorExpecting the Email file to render and postmark to send email: removed options data and api key code: 'ERR_MODULE_NOT_FOUND' What's your node version? (if relevant)v18.14.0 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @liydaco, Summary:
ExplanationNode js by default doesn't work with es6 imports and jsx files out of the box. There has to be some configuration to get them to work. By far the most popular way is to setup A bit on BabelBabel is a powerful JavaScript compiler and when it comes to using JSX with ES6 imports in Node.js, Babel plays a significant role in transpiling JSX and handling ES6 modules. Once we setup babel and the configuration, we can now transpile our code to a format that node can understand and run with no hassle. I hope this helps you! |
Beta Was this translation helpful? Give feedback.
-
I solved it simply by adding |
Beta Was this translation helpful? Give feedback.
Hi @liydaco,
Summary:
The issue is with
node
andjsx
filesSolution in this repo.
yarn dev
Explanation
Node js by default doesn't work with es6 imports and jsx files out of the box. There has to be some configuration to get them to work. By far the most popular way is to setup
Babel
.A bit on Babel
Babel is a powerful JavaScript compiler and when it comes to using JSX with ES6 imports in Node.js, Babel plays a significant role in transpiling JSX and handling ES6 modules.
Once we setup babel and the configuration, we can now transpile our code to a format that node can understand and run with no hassle.
I hope this helps you!