Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot resolve file or directory 'react/addons' (from require(react/addons) #3

Closed
adrienharnay opened this issue Apr 27, 2016 · 2 comments

Comments

@adrienharnay
Copy link

adrienharnay commented Apr 27, 2016

Hello,

First of all, thanks for your work on React Fetch. I've just installed it in my project using npm, but when I try to run webpack, I get:

ERROR in ./~/react-fetch/build/react-fetch.js
Module not found: Error: Cannot resolve 'file' or 'directory' E:\Users\Adrien\Documents\GitHub\brigad-admin-frontend/node_modules/react/addons in E:\Users\Adri
 @ ./~/react-fetch/build/react-fetch.js 17:19-42

Here's my webpack.config.js:

const webpack = require('webpack');
const path = require('path');

const nodeDir = `${__dirname}/node_modules`;

const config = {
  resolve: {
    alias: {
      react: `${nodeDir}/react`,
      'react-dom': `${nodeDir}/react-dom`,
      'react-router': `${nodeDir}/react-router`,
      'react-fetch': `${nodeDir}/react-fetch`,
      'react-bootstrap': `${nodeDir}/react-bootstrap`,
      velocity: `${nodeDir}/velocity-animate`,
      moment: `${nodeDir}/moment`,
      slimscroll: `${nodeDir}/slimscroll`,
    },
  },
  entry: {
    routes: [
      './public/src/routes/js/main',
    ],
    vendors: [
      'react', 'react-dom', 'react-router', 'react-fetch', 'react-bootstrap',
      'velocity', 'moment', 'slimscroll',
    ],
  },
  output: {
    path: path.join(__dirname, 'public/dist'),
    filename: 'bundles/[name].bundle.js',
    chunkFilename: 'chunks/[name].chunk.js',
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        include: path.resolve(__dirname, 'public'),
        loader: 'babel',
      },
      {
        test: /\.css$/,
        include: path.join(__dirname, 'public'),
        loader: 'style!css-loader?modules&importLoaders=1' +
        '&localIdentName=[name]__[local]___[hash:base64:5]',
      },
    ],
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin('vendors', './bundles/vendors.js', Infinity),
  ],
};

module.exports = config;

Edit: I opened a question on StackOverflow here

Edit2: Here's an example compliant to the changes of the React API : https://gist.github.com/bebraw/77c8168e54a4ce3257f9 (credits to the author)

@zackify
Copy link
Member

zackify commented Apr 27, 2016

Should be fixed in 0.0.9. Man, can't believe the outputted code was committed to my repo. This was a long time ago :P Let me know if it's all good and I'll close.

@adrienharnay
Copy link
Author

It's all good, thanks a lot! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants