lerna/getting-started-example

npx lerna@latest init Cannot find module 'yargs-parser'

Closed this issue · 2 comments

I did everything according to the documentation, but when I ran the command npx lerna@latest inti in the prelerna branch of the get-started-example repository I got an error

node:internal/modules/cjs/loader:959
throw err;
^

Error: Cannot find module 'yargs-parser'
Require stack:

  • C:\Users\Erick\AppData\Local\npm-cache_npx\cf2c4a51227d3ea2\node_modules\yargs\build\index.cjs
  • C:\Users\Erick\AppData\Local\npm-cache_npx\cf2c4a51227d3ea2\node_modules\yargs\yargs
  • C:\Users\Erick\AppData\Local\npm-cache_npx\cf2c4a51227d3ea2\node_modules@lerna\cli\index.js
  • C:\Users\Erick\AppData\Local\npm-cache_npx\cf2c4a51227d3ea2\node_modules\lerna\index.js
  • C:\Users\Erick\AppData\Local\npm-cache_npx\cf2c4a51227d3ea2\node_modules\lerna\cli.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object. (C:\Users\Erick\AppData\Local\npm-cache_npx\cf2c4a51227d3ea2\node_modules\yargs\build\index.cjs:2855:16)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    'C:\Users\Erick\AppData\Local\npm-cache\_npx\cf2c4a51227d3ea2\node_modules\yargs\build\index.cjs',
    'C:\Users\Erick\AppData\Local\npm-cache\_npx\cf2c4a51227d3ea2\node_modules\yargs\yargs',
    'C:\Users\Erick\AppData\Local\npm-cache\_npx\cf2c4a51227d3ea2\node_modules\@lerna\cli\index.js',
    'C:\Users\Erick\AppData\Local\npm-cache\_npx\cf2c4a51227d3ea2\node_modules\lerna\index.js',
    'C:\Users\Erick\AppData\Local\npm-cache\_npx\cf2c4a51227d3ea2\node_modules\lerna\cli.js'
    ]
    }

After the command npx lerna init outputs this

lerna notice cli v6.0.3
lerna info Updating package.json
lerna info Updating lerna.json
lerna info Creating packages directory
lerna success Initialized Lerna files
lerna info New to Lerna? Check out the docs: https://lerna.js.org/docs/getting-started

but I don't notice these things in the folder

add lerna to the root package.json
generate a lerna.json
configure a npm/yarn/pnpm workspace
image
image

I globally installed "yargs-parser" but that didn't help either. If I'm doing something wrong then help me out with this error which is related to this repository. In other projects lerna works fine.

Judging from the content of the error, it could be a npm/npx cache issue. You could try npm cache clean to clear your npm cache.

Closing this issue as it was fixed in Lerna.