• Register
0 votes

Problem :

I have the React project using the Webpack and Babel. When I created it on the office computer, my Webpack ran fine. But when I cloned my project onto the personal computer, it gave me below error :

ERROR in ./react_minesweeper.jsx
Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/alecxe/Desktop"at /alecxe/louisstephancruz/Desktop/w6d5/minesweeper/node_modules/babel-core/lib/transformation/file/options/option-manager.js:298:19 at Array.map (native) at OptionManager.resolvePresets (/Users/alecxe/Desktop/w6d5/minesweeper/node_modules/babel-core/lib/transformation/file/options/option-manager.js:269:20)


6 5 3
7,540 points

1 Answer

0 votes

Solution :

1.  Command npm i or npm install :

You should install all your packages in the package.json dependencies and the dev dependencies

2.  To check if you have the particular package installed :

You can use the below command to check particular package

npm ls babel-preset-es2015

3.  If for some of the reason the NODE_ENV is production and you want to install dev dependencies then you can use:

npm install --only=dev

4.  The below command can be used on the production machines that are dealing with the already built code and do not need the access to any of the development dependencies:

npm install --only=prod

5.  I want to recommend creating the .babelrc in your root of the repo with a below content:

{"presets": [ "es2015", "react" ] }

6.  For your webpack config you must want to specify some of the other options:

{ context: __dirname, resolve: { root: __dirname, extensions: [ '.js', '.jsx', '.json' ] }}

This will resolve your issue.

9 7 4
38,600 points

Related questions

0 votes
1 answer 1K views
Problem : I have a carousel file in which I want to get my index.js and build the block.build.js, and my webpack.config.js But I face below error message: ERROR in ./index.js Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions. Does anyone know the solution on this?
asked Jan 18 jwilliam 3.9k points
0 votes
1 answer 1.4K views
Problem : While I was trying to set up the React within Django project I came across below error ModuleBuildError in Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: C:\Users\jwilliam\Cebula3\cebula_react\assets\js\index.js: Support for the ... : [ "@babel/plugin-proposal-class-properties" ] } But the above error is still existed, How can I fix the error??
asked Jan 20 jwilliam 3.9k points
1 vote
1 answer 420 views
Problem : Currently I am trying to learn the Node, Webpack , Babel. I have recently joined a new project so need to learn these three technologies. Now I am facing below error while trying to build my project. “Module build failed (from ./node_modules/babel-loader/lib/index.js)”. ... .7.0", "webpack": "^4.17.1", "webpack-dev-server": "^3.1.7" } Please guide me in fixing above error.
asked Mar 31 morrisBson 3.2k points
0 votes
1 answer 96 views
Problem: I have recently started learning about React, Babel, JSX and JS. Now I am receiving an error from a babel if I tried to compile my JSX code into a JS code. Please find the error: “Jsx value should be either an expression or a quoted jsx text.&rdquo ... out in my searching on interenet that prop values should be passed only between {}, but adding these to my code did not help me.
asked Aug 13 Raphael Pacheco 4.9k points
1 vote
2 answers 156 views
Problem : I am very new to Ionic, I have recently started working on Ionic but I am facing below error: Runtime Error Uncaught (in promise): Error: Module build failed: Error: ENOENT: no such file or directory, open '/Users/stewart/Development/ionic/theWhoZoo/src/pages ... say they do match. import { MyRatingModel } from '../model/myratingModel'; How can I fix above error need Ionic expert help.
asked Apr 22 stewart 4k points