天天看点

taro 安装/更新报错记录

最近接了个微信项目,使用taro来开发,经常taro init 项目的时候,发现项目都不完整, 所以想到是不是包错误,卸载重装,发现报如下错误:

记录时间:2020-03-06

执行的命令

npm install -g @tarojs/cli
           

报的错误:

npm ERR! path D:\Program Files (x86)\node\node_global\node_modules\@tarojs\cli\node_modules\.bin\rimraf.cmdnpm ERR! code EEXIST
npm ERR! Refusing to delete D:\Program Files (x86)\node\node_global\node_modules\@tarojs\cli\node_modules\.bin\rimraf.cmd: is outside D:\Program Files (x86)\node\node_global\node_modules\@tarojs\cli\node_modules\rimraf and not a link
npm ERR! File exists: D:\Program Files (x86)\node\node_global\node_modules\@tarojs\cli\node_modules\.bin\rimraf.cmd
npm ERR! Move it away, and try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\Program Files (x86)\node\node_cache\_logs\2020-03-06T01_47_59_712Z-debug.log
           

截图:

taro 安装/更新报错记录

taro 的论坛资料很少,查了很久都没找到解决方案, 关注到一个错误里面的关键语句:

Refusing to delete D:\Program Files (x86)\node\node_global\node_modules\@tarojs\cli\node_modules\.bin\rimraf.cmd: is outside D:\Program Files (x86)\node\node_global\node_modules\@tarojs\cli\node_modules\rimraf and not a link
           

发现可能是npm 的原因,导航到这个文件地址,删除掉整个tarojs/cli包文件夹

再次执行:

npm install -g @tarojs/cli
           

安装成功!

npm包安装错误问题参考:http://www.bubuko.com/infodetail-3367068.html

但是当执行时又出现错误,因为我的项目在另一个文件夹,把除了node_modules文件夹的所有文件都copy了过去,正常的 yarn install 、 yarn dev:weapp。

但是却报如下错误:

PS F:\wx-web> yarn run dev:weapp
yarn run v1.19.1
$ npm run build:weapp -- --watch

> [email protected] build:weapp F:\wx-web
> taro build --type weapp "--watch"

文件名、目录名或卷标语法不正确。
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:weapp: `taro build --type weapp "--watch"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build:weapp script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\Program Files (x86)\node\node_cache\_logs\2020-03-06T03_52_17_620Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
           

截图:

taro 安装/更新报错记录

后使用:

npm run dev:weapp
           

成功!

但具体为什么这样还不清楚。