PacktPublishing / Full-Stack-React-Projects-Second-Edition

Full-Stack React Projects - Second Edition, published by Packt
MIT License
461 stars 538 forks source link

Unable to Run Chap3 Skeleton #57

Closed matton2 closed 3 years ago

matton2 commented 3 years ago

Hello. I am a complete novice in Node so please excuse the naive question. I have been coding along in Chapter 3 and can not get my build to run.

I get the following error when running yarn development. It looks like babel is not changing my template.js file back into normal JS but I have no idea how to fix that.

(node:178205) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
/home/matt/Desktop/programmingProjects/mernBackend-template/template.js:1
export default () => {
^^^^^^

SyntaxError: Unexpected token 'export'

I am sure I am missing something simple but just cannot figure it out. All of my code is pushed up to https://github.com/matton2/mernBackend-template for reference.

Thank you in advance!

FoggDev commented 3 years ago

Try to downgrade your Node version to 10, you can use NVM to change the Node versions quickly.

If you want to use a higher version of Node, then you will need to install some presets:

npm install @babel/preset-env @babel/preset-react

.babelrc file:

{
  "presets": ["@babel/preset-env", "@babel/preset-react"]
}