NodeJS pnpm工作区不允许在全新项目上安装依赖项'无法读取未定义的属性(阅读' manifest')'

mftmpeh8  于 2023-01-01  发布在  Node.js
关注(0)|答案(1)|浏览(316)

我试着用pnpm和lerna创建一个monorepo,不幸的是,当尝试通过pnpm安装lerna时,一切都失败了。
当前项目结构:

lerna.json内容:

{
  "packages": ["functions/*", "libs/*"],
  "version": "0.0.0",
  "npmClient": "pnpm",
  "publish": {
    "ignoreChanges": ["ignored-file", "*.md"],
    "message": "chore(release): publish",
    "registry": "https://npm.pkg.github.com"
  },
}

package.json内容:

{
  "name": "roci-backend",
  "private": true,
  "version": "0.0.0"
}

最后是pnpm-workspace. yaml:

## include
- "functions/**"
- "libs/**"

pnpm版本:7.0.1节点版本:16.15.0操作系统:win 10
错误信息:

❯ pnpm add -D -w lerna
 ERROR  Cannot read properties of undefined (reading 'manifest')

堆栈跟踪:

"stack": "pnpm: Cannot read properties of undefined (reading 'manifest')\n    at C:\\Users\\Seb\\AppData\\Roaming\\npm\\pnpm-global\\5\\node_modules\\.pnpm\\pnpm@7.0.1\\node_modules\\pnpm\\dist\\pnpm.cjs:120885:49\n    at Array.map (<anonymous>)\n    at C:\\Users\\Seb\\AppData\\Roaming\\npm\\pnpm-global\\5\\node_modules\\.pnpm\\pnpm@7.0.1\\node_modules\\pnpm\\dist\\pnpm.cjs:120882:39\n    at Array.map (<anonymous>)\n    at getImporters (C:\\Users\\Seb\\AppData\\Roaming\\npm\\pnpm-global\\5\\node_modules\\.pnpm\\pnpm@7.0.1\\node_modules\\pnpm\\dist\\pnpm.cjs:120878:34)\n    at recursive (C:\\Users\\Seb\\AppData\\Roaming\\npm\\pnpm-global\\5\\node_modules\\.pnpm\\pnpm@7.0.1\\node_modules\\pnpm\\dist\\pnpm.cjs:120900:31)\n    at async handler (C:\\Users\\Seb\\AppData\\Roaming\\npm\\pnpm-global\\5\\node_modules\\.pnpm\\pnpm@7.0.1\\node_modules\\pnpm\\dist\\pnpm.cjs:121294:11)\n    at async C:\\Users\\Seb\\AppData\\Roaming\\npm\\pnpm-global\\5\\node_modules\\.pnpm\\pnpm@7.0.1\\node_modules\\pnpm\\dist\\pnpm.cjs:176187:21\n    at async run (C:\\Users\\Seb\\AppData\\Roaming\\npm\\pnpm-global\\5\\node_modules\\.pnpm\\pnpm@7.0.1\\node_modules\\pnpm\\dist\\pnpm.cjs:176161:34)\n    at async runPnpm (C:\\Users\\Seb\\AppData\\Roaming\\npm\\pnpm-global\\5\\node_modules\\.pnpm\\pnpm@7.0.1\\node_modules\\pnpm\\dist\\pnpm.cjs:176379:5)"

我也试过安装许多其他旧版本,旧到5. xx,但完全相同的错误仍然存在。

mspsb9vt

mspsb9vt1#

我在没有Lerna的情况下也遇到了类似的问题,我们找到的最简单的解决方案是安装带有WSL的Linux发行版,并从Linux运行时运行pnpm命令。我让它在Windows 10 Pro,Ubuntu 22 WSL版本上工作:1

相关问题