使用vite创建vue3.0 报错 npm ERR Could not install from xxxxxxxx it does not contain a package json file

使用vite创建vue3报错 npm ERR! Could not install from xxxxxxxx it does not contain a package json file

PS G:\vue3> npm init vite-app vue3_test_vite
npm ERR! Could not install from "Files\nodejs\node_cache\_npx\4852" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Program Files\nodejs\node_cache\_logs\2021-12-22T08_21_24_218Z-debug.log
安装 [ 'create-vite-app@latest' ] 失败,错误代码:1

错误原因

node_cache路径存在空格

// 运行指令
npm config get cache
// Program Files名称存在空格
C:\Program Files\nodejs\node_cache

解决方案一

// 运行指令
npm config edit

npm config edit
将带空格的路径改写为:C:\Program~1\nodejs\node_cache

解决方案二

// 运行指令
npm config set cache "C:\Program~1\nodejs\node_cache" --global

再次运行安装指令

npm init vite-app

PS G:\vue3> npm init vite-app vue3_test_vite
npx: 7 安装成功,用时 3.371 秒
Scaffolding project in G:\vue3\vue3_test_vite...

Done. Now run:

  cd vue3_test_vite
  npm install (or `yarn`)

进入目录

 cd .\vue3_test_vite\

运行

npm i 指令

G:\vue3\vue3_test_vite> npm i

> esbuild@0.8.57 postinstall G:\vue3\vue3_test_vite\node_modules\esbuild
> node install.js

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN vue3_test_vite@0.0.0 No description
npm WARN vue3_test_vite@0.0.0 No repository field.
npm WARN vue3_test_vite@0.0.0 No license field.

added 282 packages from 277 contributors in 23.489s

31 packages are looking for funding
  run `npm fund` for details

运行

npm run dev 指令

PS G:\vue3\vue3_test_vite> npm run dev

> vue3_test_vite@0.0.0 dev G:\vue3\vue3_test_vite
> vite

[vite] Optimizable dependencies detected:
vue

  Dev server running at:
  > Network:  http://192.168.x.xx:3000/
  > Local:    http://localhost:3000/

成功

vue3.0 vite
文章参考出处: (https://blog.csdn.net/hellobbw/article/details/108402959).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值