npm 踩坑

大部分的緣由貌似都是網絡,在採起各類措施以後,仍是個人熱點救了我!css

初始想建立一個項目,使用了create命令,發現本身的vue-cli版本低,那好我就按照指令先卸載再安裝html

而後就......vue

vue create is a Vue CLI 3 only command and you are using Vue CLI 2.9.6.node

You may want to run the following to upgrade to Vue CLI 3:webpack

npm uninstall -g vue-clilaravel

npm install -g @vue/cli@3.5.xgit

卸載 vue-cli

npm uninstall -g vue-cli
複製代碼

第一個報錯來了,執行命令一直不會終止,提示了兩個warn就沒有了而後,屢次重複都是這個樣子。github

npm WARN deprecated vue-cli@2.9.6: This package has been deprecated in favour of @vue/cliweb

npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)vue-cli

在cmd中也是一樣的狀況

查看vue的版本,仍是2.9.6,並無刪除

vue -V
複製代碼

直接也沒辦法進行安裝@vue/cli

npm ERR! code Z_BUF_ERROR when install

npm ERR! code Z_BUF_ERROR when install

npm cache clean -f
複製代碼

又出現了新的錯誤 -- 意外中斷

Unexpected end of JSON input while parsing near

NPM Install Error:Unexpected end of JSON input while parsing near '…nt-webpack-plugin「:」0'

解決npm ERR!Unexpected end of JSON input while paring near (解析附近時JSON輸入意外結束)'...."^2.0.0-rc.0","glob"'等npm install錯誤

解決【npm ERR! Unexpected end of JSON input while parsing near '...sh_time":141072930277'】方案

推薦的方法,依然是 清除緩存,不行的話就反覆

方法一:清除npm緩存

  具體命令步驟:

npm cache clean --force 
//清除npm緩存
npm install @(Library you need) 
//下載安裝你須要的庫
複製代碼

方法二:刪除合併文件

  具體命令步驟:

刪除package.lock.json合併文件
npm install @(Library you need)
//下載安裝你須要的庫
複製代碼

方法三:配置默認註冊表

  具體命令步驟:  

//註冊表配置修改成默認值:
npm config set registry https://registry.npmjs.org/
複製代碼

又清除一波,再安裝,一直卡在rollbackfailedoptional中

看了不少文章,說是網絡緣由,能夠修改鏡像

npm 安裝報錯 rollbackFailedOptional verb npm-session

npm 安裝報錯 rollbackFailedOptional verb npm-session 解決辦法

npm代理

//設置npm代理
npm config set http-proxy http://server:port
npm config set https-proxy https://server:port

npm config set proxy http://127.0.0.1:1080
npm config set https-proxy http://127.0.0.1:1080

//去掉npm代理
npm config delete proxy
npm config delete https-proxy

//修改npm的資源鏡像連接
npm config set registry http://registry.npm.taobao.org
npm config set registry http://registry.npmjs.org/

//刪除代理
npm config rm proxy
npm config rm https-proxy

//查看源
npm config get registry
複製代碼

npm install Error: rollbackFailedOptional

固然以上的辦法,我都沒有采用(撓頭) 有人叫我用cnpm安裝,可是cnpm安裝的vue有好多坑在裏面:

再次嘗用原來的方法,初始化項目 init

發現 原來的vue-cli也有不少問題,出了一堆warn而後就沒有動靜了,也沒有結束

如下:

npm WARN不推薦使用extract-text-webpack-plugin@3.0.2:不推薦使用。 請使用https://github.com/webpack-contrib/mini-css-extract-plugin

npm WARN不推薦使用的browserslist@2.11.3:Browserslist 2在讀取其餘工具中使用的Browserslist> 3.0 config時可能失敗。

npm WARN不推薦使用core-js@2.6.11:因爲問題的數量,再也不維護core-js @ <3,不建議使用它。 請將您的依賴項升級到core-js @ 3的實際版本。

npm WARN不推薦使用bfj-node4@5.3.1:切換到bfj軟件包以獲取修復和新功能!

npm WARN不推薦使用json3@3.3.2:請使用本機JSON對象而不是JSON 3

npm WARN不推薦使用的browserslist@1.7.7:Browserslist 2在讀取其餘工具中使用的Browserslist> 3.0 config時可能失敗。

npm WARN不推薦使用的襪子@ 1.1.10:若是使用2.x分支,請至少升級到2.1.6,以免套接字數據流出現嚴重的錯誤以及2.1.0中引入的導入問題

npm WARN不推薦使用Circular-json@0.3.3:CircularJSON僅在維護中,flatted是其後續版本。

npm WARN不推薦使用left-pad@1.3.0:使用String.prototype.padStart()

而後起色來了,我換了本身的熱點,考慮到是否是我家的網絡問題

vue init

糟糕! 有些不對勁! :(

ESLint:5.14.0。

ESLint找不到插件「 eslint-plugin-vue」。 發生這種狀況可能有多種緣由:

1.若是ESLint是全局安裝的,請確保eslint-plugin-vue也已全局安裝。 全局安裝的ESLint

2.若是ESLint安裝在本地,則多是該插件未正確安裝。

(說個人ESlint有問題)

再試下

終於出現了 移除的字樣!!!

我來試試vue命令還能不能生效 -- 果然不存在了

core-js@<3 is no longer maintained

npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not r ecommended for usage due to the number of issues. Please, upgrade your dependenc ies to the actual version of core-js@3.

npm WARN已棄用的core-js@2.6.11: core-js@<3再也不維護,因爲問題的數量,不建議使用。請將您的dependenc升級到core-js@3的實際版本。

好,我升級!又出錯了

npm ERR!代碼ETARGET npm錯誤!沒有爲core-js@3找到匹配的版本。npm ERR!大多數狀況下,你或者你的一個依賴項都沒有請求npm。不要針對不存在的包版本。

說是不存在版本?

那我再試試

npm install --save core-js@^3
複製代碼

npm WARN saveError ENOENT:沒有此類文件或目錄,請打開「 E:\ Project \ vue \ package.json」

npm通知建立了一個做爲package-lock.json的鎖文件。 您應該提交此文件。

npm WARN ENTENT ENOENT:沒有這樣的文件或目錄,請打開「 E:\ Project \ vue \ package.json」

npm WARN vue沒有描述

npm WARN vue沒有存儲庫字段。

npm WARN vue沒有自述數據

npm WARN vue沒有許可證字段。

應該是文件夾不對。 當前目錄下沒有package.json文件吧

反覆試了好幾遍

代碼ENOENT npm錯誤!錯誤-4058 npm錯誤!syscall統計npm錯誤!enoent:沒有這樣的文件或目錄,stat 'C:\Users\lenovo2017lyp\http:\registry.npm.taobao.org\vue\download\ ve -2.5.22.tgz' npm ERR!這與npm沒法找到文件有關。npm ERR!enoent npm犯錯!

好了,應該算是把 @vue/cli安裝上了,長舒一口氣......

等着個人好戲還在後面

Vue packages version mismatch:

  • vue@2.5.22 (C:\Users\lenovo2017lyp\node_modules_vue@2.5.22@vue\dist\vue.runti me.common.js)
  • vue-template-compiler@2.6.11 (C:\Users\lenovo2017lyp\AppData\Roaming\npm\node_ modules@vue\cli\node_modules\vue-template-compiler\package.json)

This may cause things to work incorrectly. Make sure to use the same version for both. If you are using vue-loader@>=10.0, simply update vue-template-compiler. If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify sho uld bump vue-template-compiler to the latest.

版本不一致

「 Vue軟件包版本不匹配」錯誤?

vue軟件包不一致

npm i vue-template-compiler@latest --save
npm update vue-template-compiler
npm i vue@latest --save
npm update vue-loader
複製代碼

安裝的位置不對

npm install vue@2.6.11 -g
複製代碼

再試一次

貌似是不被容許,多是網絡的緣由

我再試試

終於成功啦!!!!

相關文章
相關標籤/搜索