umijs / plugins

🍣 The one-stop shop for official Umi plugins and presets.
348 stars 238 forks source link

[Bug] build出现错误,必须先dev一下 #133

Closed Ele-Lee closed 4 years ago

Ele-Lee commented 4 years ago

What happens?

我本地dev开完之后,本地build打包没有问题。 推到服务器构建就出了问题。 初步判断。如果不dev一下,直接打包会报错。 如果不dev一下,src/.umi就会不存在,直接build就会出问题,会生成src/.umi和src/.umi-production

报错信息如下

umi proxy [/auth] ====> http://courseauth.uae.shensz.local

✖ Webpack
  Compiled with some errors in 48.72s

 ERROR  Failed to compile with 2 errors                                                          13:47:24

This dependency was not found:

* @/.umi/qiankunContext in ./node_modules/@umijs/plugin-qiankun/lib/slave/runtimePlugin.js, ./src/.umi-production/core/umiExports.ts

To install it, you can run: npm install --save @/.umi/qiankunContext
Child

    ERROR in ./node_modules/@umijs/plugin-qiankun/lib/slave/runtimePlugin.js
    Module not found: Error: Can't resolve '@/.umi/qiankunContext' in '/Users/elelee/Desktop/projects/guocha/node_modules/@umijs/plugin-qiankun/lib/slave'
     @ ./node_modules/@umijs/plugin-qiankun/lib/slave/runtimePlugin.js 30:17-49
     @ ./src/.umi-production/core/plugin.ts
     @ ./src/.umi-production/umi.ts
     @ multi ./node_modules/@umijs/bundler-webpack/lib/getConfig/runtimePublicPathEntry.js ./src/.umi-production/umi.ts

    ERROR in ./src/.umi-production/core/umiExports.ts
    Module not found: Error: Can't resolve '@/.umi/qiankunContext' in '/Users/elelee/Desktop/projects/guocha/src/.umi-production/core'
     @ ./src/.umi-production/core/umiExports.ts 6:0-55 6:0-55
     @ ./node_modules/umi/dist/index.esm.js
     @ ./node_modules/@umijs/plugin-qiankun/lib/slave/lifecycles.js
     @ ./src/.umi-production/umi.ts
     @ multi ./node_modules/@umijs/bundler-webpack/lib/getConfig/runtimePublicPathEntry.js ./src/.umi-production/umi.ts
build failed
Error: build failed
    at compiler.run (/Users/elelee/Desktop/projects/guocha/node_modules/@umijs/bundler-webpack/lib/index.js:107:27)
    at finalCallback (/Users/elelee/Desktop/projects/guocha/node_modules/webpack/lib/MultiCompiler.js:254:12)
    at runWithDependencies.err (/Users/elelee/Desktop/projects/guocha/node_modules/webpack/lib/MultiCompiler.js:277:6)
    at done (/Users/elelee/Desktop/projects/guocha/node_modules/neo-async/async.js:2931:13)
    at runCompilers (/Users/elelee/Desktop/projects/guocha/node_modules/webpack/lib/MultiCompiler.js:181:48)
    at err (/Users/elelee/Desktop/projects/guocha/node_modules/webpack/lib/MultiCompiler.js:188:7)
    at compiler.run (/Users/elelee/Desktop/projects/guocha/node_modules/webpack/lib/MultiCompiler.js:270:7)
    at finalCallback (/Users/elelee/Desktop/projects/guocha/node_modules/webpack/lib/Compiler.js:257:39)
    at hooks.done.callAsync.err (/Users/elelee/Desktop/projects/guocha/node_modules/webpack/lib/Compiler.js:273:13)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/elelee/Desktop/projects/guocha/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:42:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/elelee/Desktop/projects/guocha/node_modules/tapable/lib/Hook.js:154:20)
    at onCompiled (/Users/elelee/Desktop/projects/guocha/node_modules/webpack/lib/Compiler.js:271:21)
    at hooks.afterCompile.callAsync.err (/Users/elelee/Desktop/projects/guocha/node_modules/webpack/lib/Compiler.js:681:15)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/Users/elelee/Desktop/projects/guocha/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (/Users/elelee/Desktop/projects/guocha/node_modules/tapable/lib/Hook.js:154:20)
    at compilation.seal.err (/Users/elelee/Desktop/projects/guocha/node_modules/webpack/lib/Compiler.js:678:31)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

最小可复现仓库

https://github.com/lei3536/qiankunSonApp

复现步骤,错误日志以及相关配置

相关环境信息

sorrycc commented 4 years ago

看报错应该是写死 .umi 。

Ele-Lee commented 4 years ago

看报错应该是写死 .umi 。

请问”应该是写死.umi“什么意思呢。别人拉下来,src目录下是没有.umi系列文件夹的,这个时候build会报这种错,有什么好的解决办法吗。别人来我代码,不能不git ingnore /umi吧

sorrycc commented 4 years ago

@lei3536 不是你的问题,应该是 qiankun 插件的问题。

kuitos commented 4 years ago

@lei3536 @umijs/plugin-qiankun 2.0.6

dengnan123 commented 4 years ago

现在解决了吗