Reputation: 571
I am new to this babel and with some experience in nodejs. My package.json files has a babel
"@babel/preset-react": "^7.10.4", "@nuxtjs/eslint-config": "^0.0.1", "babel-cli": "^6.26.0",
These dependencies related to babel. Got this project form some developer who is unable to work. After installing dependencies and other things. When I try to run the project via nuxtjs give me following error:
.........................................................................................................................................................................................
Must use import to load ES Module: /home/jaskaran/Downloads/electrictourcompany.com-master/node_modules/@babel/runtime/helpers/esm/objectSpread2.js require() of ES modules is not supported. require() of /home/jaskaran/Downloads/electrictourcompany.com-master/node_modules/@babel/runtime/helpers/esm/objectSpread2.js from /home/jaskaran/Downloads/electrictourcompany.com-master/node_modules/vue-server-renderer/build.dev.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename objectSpread2.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/jaskaran/Downloads/electrictourcompany.com-master/node_modules/@babel/runtime/helpers/esm/package.json.
............................................................................................................................................................................
I have already tried renaming and removing the type module from the node_module folder which is usually recommend. Now I am lost on moving forward
Upvotes: 5
Views: 1568
Reputation: 2424
I understand it's been a year but did you try upgrading or downgrading the version of @babel/runtime?
I'm using version 7.14.6 and it doesn't have the "type: module" and it works fine
this is a known issue with node v12.11.0 which was resolved in v12.11.1
If you're facing this issue because of sub-dependencies you can add the working version to resolutions in your package.json.
Upvotes: 1