yarn create @umijs/umi-app 报错:文件名、目录名或卷标语法不正确。

一、问题场景

使用 @umijs/umi-app 为模板,创建一个项目:

yarn create @umijs/umi-app

创建失败,报如下错误:

think@think-PC MINGW64 /e/zny-projects/demo01-umi
$ yarn create @umijs/umi-app
yarn create v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.1.2: The platform "win32" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@umijs/create-umi-app > @umijs/utils > @babel/register@7.8.6" has unmet peer dependency "@babel/core@^7.0.0-0".
[4/4] Building fresh packages...
success Installed "@umijs/create-umi-app@3.0.12" with binaries:
      - create-umi-app
文件名、目录名或卷标语法不正确。
error Command failed.
Exit code: 1
Command: D:\Develop\nodejs\node_global\bin\create-umi-app
Arguments:
Directory: E:\zny-projects\demo01-umi
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

image

二、问题分析及解决方案

1、我是用 npm 安装的 yarn :

npm i yarn tyarn -g

2、我重新设定了 npm 全局包的安装位置 和 缓存位置。

// 查看 npm 全局包的安装位置
npm config get prefix    // D:\Develop\nodejs\node_global
// 查看 npm 缓存位置
npm config get cache   // D:\Develop\nodejs\node_cache

image

3、查看 yarn 命令的目录:

yarn global bin 
// D:\Develop\nodejs\node_global\bin

image

4、将获取到的 yarn 命令的目录配置到环境变量 Path 上。

image

到这一步之后,我再尝试执行命令 yarn create @umijs/umi-app,问题并没有解决,还是报同样的错误。

5、查看 yarn 的全局安装位置:

yarn global dir
// C:\Users\think\AppData\Local\Yarn\Data\global

image


可以发现,yarn 的全局安装位置 和 bin 的位置不一致。

6、修改 yarn 的全局安装位置

将 yarn 的全局安装位置 修改为和 npm 的一致。

因为我的 npm 的位置是 "D:\Develop\nodejs",那么我在 "D:\Develop" 下创建一个 yarn 文件夹,在 yarn 文件夹下再创建一个 global 文件夹和一个 cache 文件夹。

然后执行下面的命令,来设置 yarn 的全局安装位置和 缓存位置:

yarn config set global-folder "D:\Develop\yarn\global"
yarn config set cache-folder "D:\Develop\yarn\cache"

image

image

7、再查看 yarn 的全局安装位置 和缓存位置

$ yarn global dir
// D:\Develop\yarn\global


$ yarn cache dir
// D:\Develop\yarn\cache\v6

说明上一步的修改操作成功。

8、再执行 yarn create @umijs/umi-app

再执行 :

yarn create @umijs/umi-app

操作成功:

image

  • 36
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
apisix-dashboard编译报错 如下,请帮助解决:Error: build failed at /usr/local/apisix-dashboard/web/node_modules/@umijs/bundler-webpack/lib/index.js:177:29 at finalCallback (/usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:108196:12) at /usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:108219:6 at done (/usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:67212:13) at runCompilers (/usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:108123:48) at /usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:108130:7 at /usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:108212:7 at finalCallback (/usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:98589:39) at /usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:98605:13 at AsyncSeriesHook.eval [as callAsync] (eval at create (/usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:147581:10), <anonymous>:51:1) at AsyncSeriesHook.lazyCompileHook (/usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:147518:20) at onCompiled (/usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:98603:21) at /usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:99013:15 at AsyncSeriesHook.eval [as callAsync] (eval at create (/usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:147581:10), <anonymous>:6:1) at AsyncSeriesHook.lazyCompileHook (/usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:147518:20) at /usr/local/apisix-dashboard/web/node_modules/@umijs/deps/compiled/webpack/4/bundle4.js:99010:31
07-14
这个错误信息表明在编译 `apisix-dashboard` 项目时出现了错误。要解决这个问题,可以尝试以下几个步骤: 1. 检查项目依赖:首先,确保你的 `apisix-dashboard` 项目的依赖项已经正确安装。进入项目目录并运行 `npm install` 或者 `yarn` 命令,以确保所有依赖都被正确下载和安装。 2. 清除缓存:有时候编译错误可能是由于缓存问题导致的。尝试运行 `npm cache clean --force` 或者 `yarn cache clean` 命令来清除缓存,然后再次尝试编译项目。 3. 更新依赖:检查你的 `apisix-dashboard` 项目的依赖项是否有更新版本。你可以尝试更新一些关键依赖的版本,例如 webpack、@umijs/bundler-webpack 等。在项目根目录运行 `npm outdated` 或者 `yarn outdated` 命令来查看可更新的依赖项,并尝试更新它们。 4. 检查配置文件:检查你的 webpack 配置文件是否正确,并且没有语错误或者配置错误。确保文件路径、loader 和插件等配置项都是正确的。 5. 查看详细错误信息:尝试查看更详细的错误信息,以便定位问题所在。在终端输出中可能会有更多的错误堆栈信息,可以根据这些信息进一步分析问题并采取相应的解决措施。 如果以上步骤都没有解决问题,建议你提供更多关于错误的详细信息,例如完整的错误堆栈跟踪信息或者其他相关的错误提示,这样可以更好地帮助我们定位问题所在并提供更准确的解决方案。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值