• 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

Please log in or register to answer this question.

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 11 views
Problem: I can’t fix this issue, can anyone tell me why: Error: plugin/preset files are not allowed to export objects, only functions.
asked Mar 13 Wafa Abu Yousef 6.1k points
0 votes
1 answer 2.3K 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, 2020 jwilliam 3.9k points
0 votes
1 answer 3 views
Problem: Why I got this error: couldn't find preset "es2015" relative to directory? Who can help me?
asked Mar 27 ashik 11.2k points
0 votes
1 answer 14 views
Problem: Can anyboady help me in solving this? Support for the experimental syntax 'classproperties' isn't currently enabled.
asked Mar 7 Wafa Abu Yousef 6.1k points
0 votes
1 answer 2.6K 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, 2020 jwilliam 3.9k points
0 votes
1 answer 63 views
Problem : failed to load external module babel register
asked Feb 25 Shovo210 13.3k points
0 votes
1 answer 42 views
Problem: I am using create-react-app. I am trying to call an image from my public folder from a file inside my src/components. I am receiving this error message: Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project's node_modules/.
asked Mar 30 ummesalma 24.5k points
0 votes
1 answer 20 views
Problem: you may need an appropriate loader to handle this file type
asked Feb 17 Dan phillip 4.7k points
0 votes
1 answer 4 views
Problem: Below settings for my package.json If I run from command line npm test all jest test cases are executed properly. In case I use directly the command jest from command line I receive this error: TypeError: Path must be a string. Received undefined
asked Apr 2 ummesalma 24.5k points
1 vote
1 answer 927 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, 2020 morrisBson 3.2k points