Umi: Umi3.x Build失败 通过别名引用的模块会被当作npm依赖

Created on 17 Mar 2020  ·  6Comments  ·  Source: umijs/umi

What happens?

@/components/pageloading只是./src/components下的一个组件
却在build时报出如下错误:

[info] [webpackbar] Compiling Webpack
[success] [webpackbar] Webpack: Compiled with some errors in 16.26s
ERROR Failed to compile with 3 errors5:22:56 PM
This dependency was not found:
@/components/pageloading in ./src/.umi-production/core/routes.ts
To install it, you can run: npm install --save @/components/pageloading

Context

  • umi 3.0.1:
  • node 12.10.0:
  • Linux:

Most helpful comment

@DarcyXf 我用的是阿里云服务器 才接触这块不是很懂
错误信息是这样的:

  • @/pages/User/login in ./src/.umi-production/core/routes.ts

To install it, you can run: npm install --save @/pages/User/login
Child

ERROR in ./src/.umi-production/core/routes.ts

那我这边如果要解决这个问题 是把所有路由/组件都换成小写吗

我想你可能是把Login.tsx改名成login.tsx了吧。

然后Git默认大小写不敏感的,你在本地跑没问题,你重新clone下来的话, 就会发现少了login.tsx这个文件, 只有Login.tsx这个文件

附带:

git遇上大小写不敏感的问题

  1. 设置本地git环境识别大小写

    git config core.ignorecase false

  2. 修改文件名称, 以变更为小写为例

    • push到远程仓库后会发现, 文件重复的问题, 也就是远程仓库的文件名称存在大小写两个版本
      image-20200402164310687
  3. 删除多余的文件

    • git rm --cached src/components/Header -r
    • git rm --cached src/components/Footer -r
    • git rm --cached src/components/Menu -r
  4. 再次推送到远程仓库

    git add .
    git commit -m 'rm files'
    git push origin master
    

All 6 comments

啥情况?我在CI打包环境中也遇到了

image

注意文件名的大小写问题

@DarcyXf 请问解决了吗,我也遇到了。
但是本地运行和打包都是正常的,远程打包失败

@haoyinag 远端打包一般是Linux机器,本地是mac/win。前者文件大小写敏感,后者不敏感。 我这边的原因是因为模块(组件)易名了,大写换成了小写,但是对应的依赖代码缺没有改。所以出现了本地依赖查找不到的问题。

@DarcyXf 我用的是阿里云服务器 才接触这块不是很懂
错误信息是这样的:

* @/pages/User/login in ./src/.umi-production/core/routes.ts

To install it, you can run: npm install --save @/pages/User/login
Child

    ERROR in ./src/.umi-production/core/routes.ts

那我这边如果要解决这个问题 是把所有路由/组件都换成小写吗

@DarcyXf 我用的是阿里云服务器 才接触这块不是很懂
错误信息是这样的:

  • @/pages/User/login in ./src/.umi-production/core/routes.ts

To install it, you can run: npm install --save @/pages/User/login
Child

ERROR in ./src/.umi-production/core/routes.ts

那我这边如果要解决这个问题 是把所有路由/组件都换成小写吗

我想你可能是把Login.tsx改名成login.tsx了吧。

然后Git默认大小写不敏感的,你在本地跑没问题,你重新clone下来的话, 就会发现少了login.tsx这个文件, 只有Login.tsx这个文件

附带:

git遇上大小写不敏感的问题

  1. 设置本地git环境识别大小写

    git config core.ignorecase false

  2. 修改文件名称, 以变更为小写为例

    • push到远程仓库后会发现, 文件重复的问题, 也就是远程仓库的文件名称存在大小写两个版本
      image-20200402164310687
  3. 删除多余的文件

    • git rm --cached src/components/Header -r
    • git rm --cached src/components/Footer -r
    • git rm --cached src/components/Menu -r
  4. 再次推送到远程仓库

    git add .
    git commit -m 'rm files'
    git push origin master
    
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Artoria-0x04 picture Artoria-0x04  ·  3Comments

tauruswang picture tauruswang  ·  3Comments

y2891663091 picture y2891663091  ·  4Comments

onReadyL picture onReadyL  ·  3Comments

sorrycc picture sorrycc  ·  4Comments