• Register
0 votes
505 views

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)

 

7.5k points

Please log in or register to answer this question.

2 Answers

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.

38.6k points
0 votes

Try this:

gulp.task('babelify', () => {
  gulp.src([`${global.config.source}/**/*.js`,
            `!${global.config.source}/js/3rd/**/*`,
            `!${global.config.source}/libs/**/*`])
    .pipe(babel({ presets: ['es2015'] }))
    .pipe(gulp.dest(dist('js')));
});
4k points

Related questions

0 votes
1 answer 13 views
13 views
Problem: Is there any way around this : Module build failed: error: cannot find module 'babel-core'?
asked Jun 23 Nahil 128k points
0 votes
1 answer 44 views
44 views
Problem: I have a carousel file in which I want to get index.js and build block.build.js, so my webpack.config.js is: var config = { entry: './index.js', output: { path: __dirname, filename: 'block.build.js', }, devServer: { contentBase: './Carousel ... ./index.js Module build failed: Error: Plugin/Preset files are not allowed to export objects, only functions. Does anyone know how to solve this?
asked Apr 30 muktaa 34.6k points
0 votes
1 answer 69 views
69 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 3.2k views
3.2k 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 30 views
30 views
Problem: Does anyone know how to solve this? > Plugin/preset files are not allowed to export objects only functions
asked May 3 ochena 23.3k points
0 votes
1 answer 11 views
11 views
Problem: Error: cannot find module '@babel/core'.
asked Jul 22 Florina Gulnar 106k points
0 votes
1 answer 35 views
35 views
Problem: Need an answer for this : Couldn't find preset "env" relative to directory
asked May 24 Sawyer Parviz 168k points
0 votes
1 answer 13 views
13 views
Problem: Can anyone assist me with this issue : Module not found: error: cannot resolve 'file' or 'directory'?
asked Jun 22 Florina Gulnar 106k points
0 votes
1 answer 13 views
13 views
Problem: Why I got this error: couldn't find preset "es2015" relative to directory? Who can help me?
asked Mar 27 ashik 14.6k points
0 votes
1 answer 16 views
16 views
Problem: Uncaught referenceerror: react is not defined.
asked Jul 8 Florina Gulnar 106k points