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

react-web 报错找不到react 和Cannot resolve module 'react/lib/ReactMount' #7

Open
Derickorqq opened this issue Aug 17, 2017 · 0 comments

Comments

@Derickorqq
Copy link

运行react-web start后报错:Module not found: Error: Cannot resolve module 'react/lib/ReactMount' in D:\reactweb_workspace\firstReactWeb

package.json如下:
'use strict';

var path = require('path');
var webpack = require('webpack');
var HtmlPlugin = require('webpack-html-plugin');
var HasteResolverPlugin = require('haste-resolver-webpack-plugin');

var IP = '0.0.0.0';
var PORT = 3000;
var NODE_ENV = process.env.NODE_ENV;
var ROOT_PATH = path.resolve(__dirname, '..');
var PROD = 'production';
var DEV = 'development';
let isProd = NODE_ENV === 'production';

var config = {
paths: {
src: path.join(ROOT_PATH, '.'),
index: path.join(ROOT_PATH, 'index.web'),
},
};

var webpackConfig = {
ip: IP,
port: PORT,
devtool: 'cheap-module-eval-source-map',
resolve: {
alias: {
'react-native': 'ReactWeb'
},
extensions: ['', '.js', '.web.js', '.ios.js', '.android.js', '.native.js', '.jsx'],
},
entry: isProd ? [
config.paths.index
] : [
'webpack-dev-server/client?http://' + IP + ':' + PORT,
'webpack/hot/only-dev-server',
config.paths.index,
],
output: {
path: path.join(__dirname, 'output'),
filename: 'bundle.js'
},
plugins: [
new HasteResolverPlugin({
platform: 'web',
nodeModules: ['react-web']
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(isProd ? PROD : DEV),
}
}),
isProd ? new webpack.ProvidePlugin({
React: 'react'
}) : new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new HtmlPlugin(),
],
module: {
loaders: [{
test: /.json$/,
loader: 'json',
}, {
test: /.jsx?$/,
loader: 'react-hot',
include: [config.paths.src],
exclude: [/node_modules/]
}, {
test: /.jsx?$/,
loader: 'babel',
query: {
presets: ['react-native', 'stage-1']
},
include: [config.paths.src],
exclude: [path.sep === '/' ? /(node_modules/(?!react-))/ : /(node_modules\(?!react-))/]
}]
}
};
webpackConfig.resolve.alias[path.basename(ROOT_PATH, '.')] = path.join(ROOT_PATH, '.');

module.exports = webpackConfig;

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

1 participant