天天看點

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
           

成功!

但具體為什麼這樣還不清楚。