如题,
原因应该是前端配置的路由,在本地运行时跳转都由前端的路由控制的,
放到8080服务器上后,是先向服务器发出url请求然后返回,所以404。
查过方法好像要用到webpack,
试着安装后运行报错了
PS C:\workspace_react\ecommercesystem> npm run build
> ecommercesystem@0.1.0 build C:\workspace_react\ecommercesystem
> webpack
[webpack-cli] Compilation finished
assets by status 325 bytes [cached] 1 asset
./src/index.js 315 bytes [built] [code generated] [1 error]
ERROR in ./src/index.js 9:2
Module parse failed: Unexpected token (9:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| ReactDOM.render(
> <BrowserRouter>
| <App />
| </BrowserRouter>,
webpack 5.2.0 compiled with 1 error in 253 ms
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ecommercesystem@0.1.0 build: `webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ecommercesystem@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\juse\AppData\Roaming\npm-cache\_logs\2020-10-26T04_51_57_914Z-debug.log
webpack.config.js
const path = require('path')
module.exports = {
entry: './src/index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.jsx?$/,
loader: 'babel'
}, {
test: /\.css$/,
loader: 'style!css'
}, {
test: /\.less$/,
loader: 'style!css!less'
},{
test: /\.(png|jpg)$/,
loader: 'url?limit=25000'
}]
}
}
这该怎么解决?
404那个问题
我参考的是这篇文章
转载 https://www.cnblogs.com/YZH-chengdu/p/6855237.html
他那串代码我该怎么改,写在哪里?