nodejs:UNMET DEPENDENCY type@module /如何让'npm list'停止返回此错误?

hfyxw5xn  于 2023-01-08  发布在  Node.js
关注(0)|答案(1)|浏览(131)
D:\TEMP\nodejs\count>npm list
TEMP@ D:\TEMP
+-- file-type@17.1.1
+-- html2pdf.js@0.10.1
+-- html2pdf@0.0.11
+-- mysql@2.18.1
+-- sqlite3@5.0.3
`-- UNMET DEPENDENCY type@module

npm ERR! code ELSPROBLEMS
npm ERR! missing: type@module, required by TEMP@

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Luuk\AppData\Local\npm-cache\_logs\2023-01-07T17_11_04_588Z-debug-0.log
  • 这个日志文件(对我)毫无用处
  • 我确实使用谷歌搜索,但这并没有导致一个解决方案。

我删除了nodejs从我的计算机,然后重新安装它这是给出完全相同的错误.
对于重新安装,我使用node-v18.12.1-x64.msi
如何让npm list停止返回此错误?
顺便说一句:目录D:\TEMP\nodejs\count是我的Windows 11系统上的空目录。
顺便说一句:该日志文件中提到了单词error

D:\TEMP\nodejs\count>findstr /i error "C:\Users\Luuk\AppData\Local\npm-cache\_logs\2023-01-07T17_11_04_588Z-debug-0.log"

38 verbose stack Error: missing: type@module, required by TEMP@
43 error code ELSPROBLEMS
44 error missing: type@module, required by TEMP@
48 error A complete log of this run can be found in:
48 error     C:\Users\Luuk\AppData\Local\npm-cache\_logs\2023-01-07T17_11_04_588Z-debug-0.log

编辑:

  • 删除node_modules目录(move node_modules node_modules.1,在C:\Program Files\nodejs目录中)后
  • 我做了npm cache clean,产生了:
D:\TEMP\nodejs\count>np chache clean
'np' is not recognized as an internal or external command,
operable program or batch file.

D:\TEMP\nodejs\count>npm chache clean
node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.12.1
node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.12.1

D:\TEMP\nodejs\count>
qfe3c7zg

qfe3c7zg1#

NPM的依赖关系解析器似乎有点坏了,因为NPM的安全建议和工具,如NPM审计,NPM列表,不能完全信任https://github.com/npm/npm/issues/1341#issuecomment-20634338
这里是一个快速修复的问题,可能会有所帮助-
步骤1 -删除node_modules目录
步骤2 -运行npm cache clean
步骤3 -运行npm install

相关问题