【问题标题】:Create-react-app cannot build. it takes long time and then got errorCreate-react-app 无法构建。需要很长时间然后出错
【发布时间】:2018-08-27 19:24:23
【问题描述】:

我有 create-react-project v15 并运行 npm run build 并需要很长时间(20 分钟)(如冻结)运行构建然后得到这个错误结果。

如何解决这个问题?

enter code heresers/rice/my-app-2/node_modules/extract-text-webpack-plugin/dist/index.js:246
        if (extractedChunk.getNumberOfModules()) {
                           ^

TypeError: extractedChunk.getNumberOfModules is nota function
at ExtractTextPlugin.<anonymous> (/Users/rice/my-app-2/node_modules/extract-text-webpack-plugin/dist/index.js:246:32)
at Array.forEach (<anonymous>)
at Compilation.<anonymous> (/Users/rice/my-app-2/node_modules/extract-text-webpack-plugin/dist/index.js:245:27)
at Compilation.applyPluginsAsyncSeries (/Users/rice/my-app-2/node_modules/react-scripts/node_modules/tapable/lib/Tapable.js:206:13)
at sealPart2 (/Users/rice/my-app-2/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:636:9)
at next (/Users/rice/my-app-2/node_modules/react-scripts/node_modules/tapable/lib/Tapable.js:202:11)
at /Users/rice/my-app-2/node_modules/extract-text-webpack-plugin/dist/index.js:241:13
at /Users/rice/my-app-2/node_modules/async/dist/async.js:421:16
at iteratorCallback (/Users/rice/my-app-2/node_modules/async/dist/async.js:998:13)
at /Users/rice/my-app-2/node_modules/async/dist/async.js:906:16
at /Users/rice/my-app-2/node_modules/extract-text-webpack-plugin/dist/index.js:224:15
at /Users/rice/my-app-2/node_modules/async/dist/async.js:421:16
at iteratorCallback (/Users/rice/my-app-2/node_modules/async/dist/async.js:998:13)
at /Users/rice/my-app-2/node_modules/async/dist/async.js:906:16
at /Users/rice/my-app-2/node_modules/extract-text-webpack-plugin/dist/index.js:213:21
at rebuilding.forEach.cb (/Users/rice/my-app-2/node_modules/react-scripts/node_modules/webpack/lib/Compilation.js:504:29)
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c react-scripts build
Directory: /Users/rice/my-app-2
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/rice/my-app-2/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

【问题讨论】:

  • 线索在错误“extractedChunk.getNumberOfModules is nota function”中。您可能没有正确导出该函数,但没有看到您的代码就无法判断。
  • 这个 package-module 来自 create react app module => extract-text-webpack-plugin。我不知道修复
  • 我的猜测是你应该将提取的Chunk.getNumberOfModules() 更改为extractChunk.getNumberOfModules ,不带()
  • @MihaiT 我在你的指导下改变了结果是一样的。冻结构建
  • 我看到了这个确切的问题 - 有什么进展吗?

标签: javascript reactjs webpack create-react-app


【解决方案1】:

也许您可以尝试删除node_modules 文件夹并再次运行npm install 以重新安装模块。
然后尝试再次运行npm run build

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-30
    • 1970-01-01
    • 2014-05-06
    • 1970-01-01
    • 1970-01-01
    • 2019-06-07
    • 1970-01-01
    相关资源
    最近更新 更多