记一次使用create react app出现webpack is not a function的情况

CentOS 7下出现报错信息如下:

[root@VM_15_35_centos /data0/www/kfe/my-reat/client]npm start

> [email protected] start /data0/www/kfe/my-reat/client
> node scripts/start.js

Failed to compile.

webpack is not a function

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start 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!     /root/.npm/_logs/2019-07-16T02_31_16_759Z-debug.log

报错提示:webpack is no function 

报错信息文件:npm ERR! [email protected] start: `node scripts/start.js`

打开文件会有:

记一次使用create react app出现webpack is not a function的情况_第1张图片

将react-dev-utils升级到v8.0.0之后。createCompiler()函数已更改为期望对象而不是多个参数(笔者认为这将在未来提供更大的灵活性)

const compiler = createCompiler(webpack, config, appName, urls, useYarn);

更改为对象 createCompiler({}):

const compiler = createCompiler({ webpack, config, appName, urls, useYarn })

这里笔者发现一篇 create-react-app 源码解析之react-scripts 有空的话可以看一下

你可能感兴趣的:(记一次使用create react app出现webpack is not a function的情况)