簡體   English   中英

什么是錯誤率! 代碼 ENOLOCAL npm ERR! 無法安裝錯誤?

[英]What is the ERR! code ENOLOCAL npm ERR! Could not install from error?

我要更新 npm 最新版本,但它顯示此錯誤消息,

G:\>npm i -g npm ERR! code ENOLOCAL npm ERR! Could not install from "" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\hemanth\AppData\Roaming\npm-cache\_logs\2018-01-08T03_34_29_774Z-debug.log

G:\>

在此處輸入圖片說明

這是 node 中的一個問題,它是由 Windows 用戶名中的空格引起的(可能在 Windows 中的名字和姓氏之間)。

在具有管理員訪問權限的命令提示符中將 firstname 替換為 Windows 用戶 firstname 后運行以下命令

npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global

這對我有用:

npm cache verify

然后我重新運行:

npm install -g create-react-app

它按預期安裝:問題已解決

終端輸出截圖

我遇到了同樣的問題,因為我使用的是來自另一個系統的更新的“package-lock.json”文件,並且在我遇到問題的系統上沒有“node_modules”文件夾。

您可以嘗試以下操作:

  1. 將“package-lock.json”移動到當前目錄之外的其他文件夾。
  2. 安裝

如果您遇到此問題,首先應該使用以下代碼更新 npm:

npm -g install npm

然后嘗試創建 React 文件。 它對我來說是 100% 的工作。

在管理員模式下運行 CMD 並按順序執行以下命令

  1. 以管理員身份運行cmd
  2. 運行 npm config edit (您將獲得記事本編輯器)
  3. 將前綴變量更改為 C:\\Users\\AppData\\Roaming\\npm
  4. npm install -g create-react-app 轉到鏈接以獲取更多npm - EPERM:Windows 上不允許操作謝謝。

我收到錯誤 npm ERR! 運行 npx create-react-app my-app uninstall and install 時的代碼 ENOLOCAL 對我有用... npm uninstall -g create-react-app

npm install -g create-react-app 這將升級你的 npx,然后運行 ​​npx create-react-app my-app 這工作正常

npm cache verify
npm install -g create-react-app

這對我有用:

npm install -g degit

就像升級一樣

請驗證,你的npm是否在 **%AppData%Roaming\\npm\\node_modules** 安裝了create-react-app

如果沒有,則使用命令安裝它

npm install -g create-react-app

我將更新npm最新版本,但顯示此錯誤消息,

G:\>npm i -g npm ERR! code ENOLOCAL npm ERR! Could not install from "" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\hemanth\AppData\Roaming\npm-cache\_logs\2018-01-08T03_34_29_774Z-debug.log

G:\>

在此處輸入圖片說明

在最新的 Windows 中,防火牆會阻止 node.exe 創建 package.json。 所以關閉防火牆設置並嘗試一次,它對我有用。

我在嘗試將 sevelte 與命令一起使用時遇到了同樣的問題

npx degit sveltejs/template youproject

以下內容很有用:

install -g degit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM