簡體   English   中英

在 Windows 10 中安裝節點后,npm 命令失敗並出現錯誤找不到模塊“lru_cache”

[英]After installing node in Windows 10, npm command is failing with error cannot find module 'lru_cache'

在 Windows 10 機器上安裝了 Node v14.16.1。 打開命令提示符並輸入打印的“節點”

D:\>node
Welcome to Node.js v14.16.1.
Type ".help" for more information.
>

現在,在另一個命令提示符下鍵入錯誤的“npm”

Microsoft Windows [Version 10.0.19041.928]
(c) Microsoft Corporation. All rights reserved.

D:\>npm
internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'lru-cache'
Require stack:
- C:\Users\icando\AppData\Roaming\npm\node_modules\npm\node_modules\semver\classes\range.js
- C:\Users\icando\AppData\Roaming\npm\node_modules\npm\node_modules\semver\classes\comparator.js
- C:\Users\icando\AppData\Roaming\npm\node_modules\npm\node_modules\semver\index.js
- C:\Users\icando\AppData\Roaming\npm\node_modules\npm\lib\utils\unsupported.js
- C:\Users\icando\AppData\Roaming\npm\node_modules\npm\lib\cli.js
- C:\Users\icando\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
←[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:725:27)←[39m
←[90m    at Module.require (internal/modules/cjs/loader.js:952:19)←[39m
←[90m    at require (internal/modules/cjs/helpers.js:88:18)←[39m
    at Object.<anonymous> (C:\Users\icando\AppData\Roaming\npm\node_modules\←[4mnpm←[24m\node_modules\←[4msemver←[24m\classes\range.js:187:13)
←[90m    at Module._compile (internal/modules/cjs/loader.js:1063:30)←[39m
←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
←[90m    at Module.require (internal/modules/cjs/loader.js:952:19)←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: [
    ←[32m'C:\\Users\\icando\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\semver\\classes\\range.js'←[39m,
    ←[32m'C:\\Users\\icando\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\semver\\classes\\comparator.js'←[39m,
    ←[32m'C:\\Users\\icando\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\semver\\index.js'←[39m,
    ←[32m'C:\\Users\\icando\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\utils\\unsupported.js'←[39m,
    ←[32m'C:\\Users\\icando\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js'←[39m,
    ←[32m'C:\\Users\\icando\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'←[39m
  ]
}

D:\>

有人可以幫助解決此錯誤。 我公平地搜索了這個錯誤來解決,但似乎沒有任何幫助。 我嘗試再次卸載和安裝 node.js 但沒有運氣。 我非常感謝您的幫助。

Nodejs Windows 10 安裝程序(Node-v14.16.1-x64.msi)很亂,我相信這是導致錯誤的原因。 我已經卸載並下載了 Windows Binary (.zip) 並在 PATH 環境變量中設置了擴展目錄。 這樣,我就可以使用 npm 命令。

暫無
暫無

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

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