簡體   English   中英

如何使用 loadVirtual 和 ENOLOCK 修復 npm 審計錯誤?

[英]how to fix npm audit error with loadVirtual and ENOLOCK?

➜   npm audit
npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file

我運行了 npm 審計並得到了這個錯誤。

當我在下面運行時:

➜ npm config get package-lock
true

➜ npm config get shrinkwrap
true

有人可以幫忙嗎? 至於如何解決? 和 npm 審計修復 --force 不能正常工作......

我剛剛運行了它所說的命令。

npm i --package-lock-only

然后它向我展示了 0 個漏洞。 無論如何,再次運行審核修復並再次運行 0 個漏洞。

像這樣為我工作:

npm cache clean --force

npm fund

npm audit fix --force

該錯誤告訴您問題的根源: This command requires an existing lockfile. . 這意味着您在嘗試審核的package.json旁邊還沒有package-lock.json npm i --package-lock-only只生成/更新 package-lock.json 無需重新安裝; npm i將重新安裝並生成一個(基於您的配置)。

您需要創建 package-lock.json,運行

npm install

然后

npm audit fix

你不會有問題

我用npm install -g npm@8.3.0更新到最新版本的 npm ,現在它顯示沒有更多問題了......

嘗試運行這些:

npm i --package-lock-only
npm config get package-lock
npm config get shrinkwrap
npm i --package-lock-only
npm audit fix

這里

試試這些命令。

npm i --package-lock-only
npm config get package-lock
npm config get shrinkwrap
npm i --package-lock-only
npm audit fix

使用 Node 14,它修復了 0 個漏洞的問題。

我讀了這個,真的很有幫助:

https://medium.com/illumination/how-to-fix-npm-audit-error-with-loadvirtual-and-enolock-deprecated-dependencies-1f07ba65eef9

npm i --package-lock-only npm config get package-lock npm config get shrinkwrap npm i --package-lock-only npm audit fix

(當運行 'npm config get package-lock' 和 'npm config get shrinkwrap' 時,您將收到兩者的 'true')— → 運行 'npm audit fix' 后,您將看到:“up to date, audited... found 0個漏洞”

問題是因為您需要一個 package.json 和 package-lock.json 文件運行這些命令將為您修復它。

npm 初始化-y

npm i --package-lock-only

npm審核

這解決了問題

有同樣的錯誤,然后意識到我在父文件夾中。 因此,如果沒有鎖定文件,可能會發生這種情況。

嘗試運行此命令:npm cache clean --force

暫無
暫無

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

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