【问题解决】docker内青龙面板,Error: Cannot find module ‘got‘解决方法。
·
碰到的问题如下:
(总结主要是npm 工具本身存在一些问题,所以换个工具装got即可)
node:internal/modules/cjs/loader:1404
throw err;
^
Error: Cannot find module 'got'
Require stack:
- /ql/data/scripts/shufflewzc_faker4_main/jd_autock.js
at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
at Function._load (node:internal/modules/cjs/loader:1211:37)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Module.require (node:internal/modules/cjs/loader:1487:12)
at require (node:internal/modules/helpers:135:16)
at Object.<anonymous> (/ql/data/scripts/shufflewzc_faker4_main/jd_autock.js:16:33569)
at Module._compile (node:internal/modules/cjs/loader:1730:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/ql/data/scripts/shufflewzc_faker4_main/jd_autock.js' ]
}
Node.js v22.16.0
先进入docker的青龙面板下:
docker exec -it qinglong bash
使用另一个包管理器 pnpm
安装并使用一个名为 pnpm 的替代工具来安装 got。pnpm 使用不同的依赖管理机制,很可能可以绕开这个导致 npm 崩溃的底层 Bug。
npm install -g pnpm
使用 pnpm 来安装 got
pnpm 安装成功后,请确保你仍然在 /ql/data 目录下,然后执行:
pnpm add got
可能碰到的报错,如果没碰到直接跳过:
root@qinglong:/ql/data $ pnpm add got
WARN Ignoring broken lockfile at /ql/node_modules/.pnpm: Lockfile /ql/node_modules/.pnpm/lock.yaml not compatible with current pnpm
WARN Ignoring broken lockfile at /ql: Lockfile /ql/pnpm-lock.yaml not compatible with current pnpm
ERR_PNPM_UNEXPECTED_STORE Unexpected store location
The dependencies at "/ql/node_modules" are currently linked from the store at "/root/.local/share/pnpm/store/v3".
pnpm now wants to use the store at "/.pnpm-store/v10" to link dependencies.
If you want to use the new store location, reinstall your dependencies with "pnpm install".
You may change the global store location by running "pnpm config set store-dir <dir> --global".
(This error may happen if the node_modules was installed with a different major version of pnpm)
发现了一个由旧版 pnpm 创建的、来自另一个旧“零件仓库”的文件夹,解决方法很简单,就是按 pnpm 的提示,移除掉旧的、由老版本创建的 node_modules 文件夹,然后让新版 pnpm 重新安装。
rm -rf /ql/node_modules
重新安装got即可:
cd /ql/data
pnpm add got
更多推荐
所有评论(0)