运行报错 Error: Cannot find module '@lerna/add/command'

运行报错 Error: Cannot find module '@lerna/add/command'

是按照老师的方法,我看很多同学都有这种问题,但是都没有解决,不知道是老师 lerna 源码和我们不一直导致的吗?(最新的 code 外层 package 没有 bin)


删除重新安装什么都试过了就是不行,就是没手动一个个从远程仓库安装他们下来


IDE 爆红就是这些 


const addCmd = require("@lerna/add/command");
const bootstrapCmd = require("@lerna/bootstrap/command");
const changedCmd = require("@lerna/changed/command");
const cleanCmd = require("@lerna/clean/command");
const createCmd = require("@lerna/create/command");
const diffCmd = require("@lerna/diff/command");
const execCmd = require("@lerna/exec/command");
const importCmd = require("@lerna/import/command");
const infoCmd = require("@lerna/info/command");
const initCmd = require("@lerna/init/command");
const linkCmd = require("@lerna/link/command");
const listCmd = require("@lerna/list/command");
const publishCmd = require("@lerna/publish/command");
const runCmd = require("@lerna/run/command");
const versionCmd = require("@lerna/version/command");



​就是这些 local dependency


"@lerna/add": "file:../../commands/add",
"@lerna/bootstrap": "file:../../commands/bootstrap",
"@lerna/changed": "file:../../commands/changed",
"@lerna/clean": "file:../../commands/clean",
"@lerna/cli": "file:../cli",
"@lerna/create": "file:../../commands/create",
"@lerna/diff": "file:../../commands/diff",
"@lerna/exec": "file:../../commands/exec",
"@lerna/import": "file:../../commands/import",
"@lerna/info": "file:../../commands/info",
"@lerna/init": "file:../../commands/init",
"@lerna/link": "file:../../commands/link",
"@lerna/list": "file:../../commands/list",
"@lerna/publish": "file:../../commands/publish",
"@lerna/run": "file:../../commands/run",
"@lerna/version": "file:../../commands/version",


弄了我几个小时,请老师指点

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

1回答
扬_灵 2021-03-08 09:16:02

同学你好,先删除yarn.lock,后在执行 lerna bootstrap --force-local试一下,如果不行,麻烦将QQ发一下,我们远程调试一下。

  • 提问者 st2020 #1

    我这里没有 yarn.lock qq:395267921

    2021-03-08 09:27:49
  • 扬_灵 回复 提问者 st2020 #2

    同学你好,lerna4.0的源码中用了 npm 的workspaces 。workspaces这个概念比较大在后面第六阶段的时候会进行更新,你可以先和课程版本保持一致进行学习https://github.com/lerna/lerna/tree/v3.22.1

    2021-03-08 15:41:37
  • 提问者 st2020 回复 扬_灵 #3
    怎么发现的?可以分享下 debug 思路吗?我咋没看出来
    2021-03-08 16:04:24
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师