我最近应用了代码分割,我正在使用CRA(create-react-app)。
之后,我将构建文件部署到heroku但是我收到了此错误消息。
error An unexpected error occurred:
"/tmp/build_bfd38a5e7aeec15ffefbe9481e36ace7/node_modules/uglifyjs-
webpack-plugin: EROFS: read-only file system, access '/usr/local/bin'".
我认为这主要是因为我的bundle.js被拆分为4个单独的块,这些块会大大改变bundle文件。
有关详细信息,请参阅我的asyncComponent.js和App.js.
// asyncComponent.js
import React, { Component } from 'react';
export default function asyncComponent (getComponent) {
return class AsyncComponent extends Component {
static Component = null;
state = {
Component: AsyncComponent.Component
};
componentWillMount () {
if (!this.state.Component) {
getComponent().then(({ default: Component }) => {
AsyncComponent.Component = Component;
this.setState({ Component });
});
}
}
render () {
const { Component } = this.state;
return Component && <Component {...this.props} />
}
};
}
// App.js
import asyncComponent from './lib/asyncComponent';
const AsyncHome = asyncComponent(() => import('./pages/Home'));
class App extends Component {
render() {
return (
<Provider store={store}>
<Router>
<div>
<Switch>
<Route exact path="/" component={ AsyncHome } />
</Switch>
</div>
</Router>
</Provider>
);
}
}
export default App
答案 0 :(得分:2)
我有同样的问题。它似乎与Yarn v1.0.0
有关。如果您明确地将您的纱线引擎设置为0.28.4
,您的构建应该再次起作用。请参阅此相关的GitHub问题:heroku-buildpack-nodejs 468
在package.json
:
"engines": {
"yarn": "0.28.4"
}