React-dates: Error: Couldn't find preset "airbnb" relative to directory

Created on 10 Apr 2017  路  7Comments  路  Source: airbnb/react-dates

What error is this? How to solve? Why no info about it in docs?

ERROR in ./~/react-dates/index.js
    Module build failed: Error: Couldn't find preset "airbnb" relative to directory "C:\\Users\\user\\app\\node_modules\\react-dates"
        at C:\Users\user\app\node_modules\babel-core\lib\transformation\file\options\option-manager.js:293:19
        at Array.map (native)
        at OptionManager.resolvePresets (C:\Users\user\app\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
        at OptionManager.mergePresets (C:\Users\user\app\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
        at OptionManager.mergeOptions (C:\Users\user\app\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
        at OptionManager.init (C:\Users\user\app\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
        at File.initOptions (C:\Users\user\app\node_modules\babel-core\lib\transformation\file\index.js:212:65)
        at new File (C:\Users\user\app\node_modules\babel-core\lib\transformation\file\index.js:135:24)
        at Pipeline.transform (C:\Users\user\app\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
        at transpile (C:\Users\user\app\node_modules\babel-loader\lib\index.js:46:20)
        at C:\Users\user\app\node_modules\babel-loader\lib\fs-cache.js:79:18
        at ReadFileContext.callback (C:\Users\user\app\node_modules\babel-loader\lib\fs-cache.js:15:14)
        at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:365:13)
     @ ./src/js/DatePicker.js 1:536-558
     @ ./src/js/widget.js

Most helpful comment

Great ! Done~ @ljharb
I add exclude in babel-loader , and it solved

module: {
    rules: [{
      test: /\.(js|jsx)$/,
      loader: 'babel-loader',
      exclude: /node_modules/,
      options: {
        presets: ['es2015','react','stage-0'],
        plugins : [["import", {
          "libraryName": "antd",
          "libraryDirectory": "lib",   // default: lib
          "style": false
        },]]
      }


    }

All 7 comments

Hi @wzup, can you check your node_modules folder for babel-preset-airbnb? It seems like your npm install did not complete for some reason. babel-preset-airbnb is a dev dependency of the repo that should have been installed when you ran npm install.

If you try installing again and get an error, can you share what that error is?

Hi, @majapw
I have manually installed babel-preset-airbnb

npm i --save babel-preset-airbnb

Then I had some issues using react-dates (https://github.com/airbnb/react-dates/issues/437 and https://github.com/airbnb/react-dates/issues/436), so I was compelled to remove react-dates and went on with another date picker plugin. Will try again with react-dates sometimes later and write my experience.

@wzup i'm confused, if you're trying to use react-dates as a dependency, you shouldn't need any of the dev deps including babel and its presets.

Hi @wzup,

Thank you for the issues. I don't think we can help you fix them without more information from you, especially since I don't think they are react-dates related but rather related to your individual setup/installation. Since you've decided to go with a different library, I'm going to close these issues. Feel free to reopen one of them if you need to in the future!

I installed react-dates by command
npm install react-dates -S
When i run dev-server :
NODE_ENV=pretest webpack-dev-server
The following tips here:

ERROR in ./~/react-dates/index.js
Module build failed: Error: Couldn't find preset "airbnb" relative to directory "/Users/Gorden/Documents/hbc-pc/node_modules/react-dates"
at /Users/Gorden/Documents/hbc-pc/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
at Array.map (native)
at OptionManager.resolvePresets (/Users/Gorden/Documents/hbc-pc/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
at OptionManager.mergePresets (/Users/Gorden/Documents/hbc-pc/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (/Users/Gorden/Documents/hbc-pc/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (/Users/Gorden/Documents/hbc-pc/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/Users/Gorden/Documents/hbc-pc/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/Users/Gorden/Documents/hbc-pc/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/Users/Gorden/Documents/hbc-pc/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at transpile (/Users/Gorden/Documents/hbc-pc/node_modules/babel-loader/lib/index.js:46:20)
at Object.module.exports (/Users/Gorden/Documents/hbc-pc/node_modules/babel-loader/lib/index.js:163:20)
@ ./mainsrc/static/daily_react/container/customization/index.jsx 33:18-40
@ ./mainsrc/static/daily_react/app.js
@ ./mainsrc/static/daily_react/index.js
@ multi ./buildScript/dev-client ./mainsrc/static/daily_react/index.js

That looks like a bug in webpack dev server; it shouldn't be trying to Babel transform anything in node_modules.

Great ! Done~ @ljharb
I add exclude in babel-loader , and it solved

module: {
    rules: [{
      test: /\.(js|jsx)$/,
      loader: 'babel-loader',
      exclude: /node_modules/,
      options: {
        presets: ['es2015','react','stage-0'],
        plugins : [["import", {
          "libraryName": "antd",
          "libraryDirectory": "lib",   // default: lib
          "style": false
        },]]
      }


    }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

kakadiadarpan picture kakadiadarpan  路  22Comments

wub picture wub  路  20Comments

majapw picture majapw  路  25Comments

mccambridge picture mccambridge  路  20Comments

aaronjensen picture aaronjensen  路  52Comments