我有一个测试应用程序,安装了以下内容:
"dependencies": {
"express": "^4.14.0",
"react": "^15.3.2",
"react-dom": "^15.3.2"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-core": "^6.18.2",
"babel-loader": "^6.2.7",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"webpack": "^1.13.3"
}
My webpack.config.js:
module.exports = {
entry: {
'bundle': './client/index.js'
},
output: {
path: './public',
filename: 'js/[name].js'
},
plugins: [
new webpack.ProvidePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
],
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: { presets: ['es2015', 'react'] }
}
]
}
}
为什么我会得到这些反应本机相关错误..??我不是想使用 React Native!
(当我删除webpack.ProvidePlugin()
错误消失了,但我需要 React 的生产版本)。
./~/react/lib/NativeMethodsMixin.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/TextInputState”
@ ./~/react/lib/NativeMethodsMixin.js 17:21-63
./~/react/lib/NativeMethodsMixin.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/UIManager”
@ ./~/react/lib/NativeMethodsMixin.js 18:16-53
./~/react/lib/ReactNativeBaseComponent.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/UIManager”
@ ./~/react/lib/ReactNativeBaseComponent.js 22:16-53
./~/react/lib/ReactNativeBaseComponent.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/deepFreezeAndThrowOnMutationInDev”
@ ./~/react/lib/ReactNativeBaseComponent.js 24:40-101
./~/react/lib/ReactNativeAttributePayload.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/deepDiffer”
@ ./~/react/lib/ReactNativeAttributePayload.js 16:17-55
./~/react/lib/ReactNativeAttributePayload.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/flattenStyle”
@ ./~/react/lib/ReactNativeAttributePayload.js 17:19-59
./~/react/lib/ReactNativeBridgeEventPlugin.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/UIManager”
@ ./~/react/lib/ReactNativeBridgeEventPlugin.js 20:16-53
./~/react/lib/ReactNativeDOMIDOperations.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/UIManager”
@ ./~/react/lib/ReactNativeDOMIDOperations.js 15:16-53
./~/react/lib/ReactNativeDefaultInjection.js 中的错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/InitializeJavaScriptAppEngine”
@ ./~/react/lib/ReactNativeDefaultInjection.js 23:0-57
./~/react/lib/ReactNativeDefaultInjection.js 中的错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/RCTEventEmitter”
@ ./~/react/lib/ReactNativeDefaultInjection.js 27:22-65
./~/react/lib/ReactNativeDefaultInjection.js 中的错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/View”
@ ./~/react/lib/ReactNativeDefaultInjection.js 79:15-47
./~/react/lib/ReactNativeGlobalResponderHandler.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/UIManager”
@ ./~/react/lib/ReactNativeGlobalResponderHandler.js 13:16-53
./~/react/lib/ReactNativeMount.js 中的错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/UIManager”
@ ./~/react/lib/ReactNativeMount.js 21:16-53
./~/react/lib/ReactNativeTextComponent.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的模块“react-native/lib/UIManager”
@ ./~/react/lib/ReactNativeTextComponent.js 19:16-53
./~/react/lib/ReactDOMFiber.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的“文件”或“目录”./ReactFiberReconciler
@./~/react/lib/ReactDOMFiber.js 15:27-60
./~/react/lib/ReactNoop.js 中出现错误
找不到模块:错误:无法解析 C:\node\sandbox\react-webpack\node_modules\react\lib 中的“文件”或“目录”./ReactFiberReconciler
@./~/react/lib/ReactNoop.js 22:27-60