我是新来的反应者,这是我尝试部署到heroku的第一个项目。 这是我的webpack配置:
module.exports = {
entry: ['./src/index.js'],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
module: {
loaders: [
{
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['react', 'es2015', 'stage-1']
}
}
]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
devServer: {
historyApiFallback: true,
contentBase: './',
watchOptions: {
aggregateTimeout: 300,
poll: 1000
}
}
};
这是我的package.json:
{
"name": "redux-simple-starter",
"version": "1.0.0",
"description": "Simple starter package for Redux with React and Babel support",
"main": "index.js",
"repository": "git@github.com:StephenGrider/ReduxSimpleStarter.git",
"scripts": {
"dev": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"postinstall": "webpack -p",
"start" : "node server.js" ,
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test",
"test:watch": "npm run test -- --watch"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.2.1",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"babel-preset-stage-1": "^6.1.18",
"loadash": "^1.0.0",
"lodash": "^3.10.1",
"prop-types": "^15.6.2",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-redux": "5.0.7",
"react-router": "^3.2.0",
"react-transition-group": "^2.4.0",
"redux": "4.0.0",
"redux-form": "^5.3.6"
}
}
还有我的server.js:
const express = require ('express')
const path = require ('path')
const port = process.env.PORT || 8080 ; //اگه پورت توسط هیروکو داده شده بود ازش استفاده میکنیم در غیر این صورت پورت 8080
const app = express()
app.use (express.static(__dirname))
app.get ("*" , (req,res) =>{ //تمام ادرس ها رو میفرستیم برای index.html
res.sendFile(path.resolve(__dirname, 'index.html'))
});
app.listen(port)
console.log("server started" +__dirname) ;
将项目部署到heroku之后,在控制台中出现以下错误:“未捕获的错误:找不到模块“ React””
我在做什么错了?