lerna: Cannot delete property '--' of # for lerna 3.18.4

I exec lerna exec -- npm view \$LERNA_PACKAGE_NAME, then an error appears:

$ lerna -v
3.18.4
$ lerna exec -- npm view \$LERNA_PACKAGE_NAME
/<proj>/node_modules/yargs/yargs.js:1184
      else throw err
           ^

TypeError: Cannot delete property '--' of #<Object>
    at Object.Yargs.self._copyDoubleDash (/<proj>/node_modules/yargs/yargs.js:1196:5)
    at Object.parseArgs [as _parseArgs] (/<proj>/node_modules/yargs/yargs.js:1097:60)
    at Object.parse (/<proj>/node_modules/yargs/yargs.js:578:25)
    at main (/<proj>/node_modules/lerna/index.js:44:6)
    at Object.<anonymous> (/<proj>/node_modules/lerna/cli.js:11:15)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)

Expected Behavior

No error

Current Behavior

The error

Possible Solution

Maybe from yargs 14.2.1

Steps to Reproduce (for bugs)

  1. create an empty respository
  2. yarn init
  3. yarn global add lerna
  4. lerna exec – npm view $LERNA_PACKAGE_NAME
lerna.json

<!-- Please paste your `lerna.json` here -->
no lerna.json

lerna-debug.log

<!-- If you have a `lerna-debug.log` available, please paste it here -->
<!-- Otherwise, feel free to delete this <details> block -->
no lerna-debug.log

Context

Your Environment

Executable Version
lerna --version 3.18.4
npm --version 6.11.3
yarn --version 1.12.1
node --version v12.12.0
OS Version
MacOS Mojave 10.14.6

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 19
  • Comments: 16 (2 by maintainers)

Commits related to this issue

Most upvoted comments

@samarpanB I tried downgrading lerna in my package.json to 3.17.0 , and it DID work for me. This is what that line looks like.

    "lerna": "3.17.0",

Ditto,

Downgrading to the following works for me for now:

"lerna": "3.17.0",

The document should be updated if this is intended: https://github.com/lerna/lerna/tree/master/commands/exec#usage Then it’s a break change.

Downgrading to version 3.17 also didnt work

@samarpanB make sure you correctly pin the version in your package.json as "3.17.0" and not "^3.17.0".

also make sure to clear out your node_modules and re-run a clean npm install (or yarn, if that’s what you use)

I’m getting this with lerna run as well when trying to pass args to the underlying npm script with lerna v3.18.4.

lerna run start --scope some-package -- -c someoption

results in:

<proj>/node_modules/yargs/yargs.js:1184
      else throw err
           ^

TypeError: Cannot delete property '--' of #<Object>
    at Object.Yargs.self._copyDoubleDash (<proj>/node_modules/yargs/yargs.js:1196:5)
    at Object.parseArgs [as _parseArgs] (<proj>/node_modules/yargs/yargs.js:1097:60)
    at Object.parse (<proj>/node_modules/yargs/yargs.js:578:25)
    at main (<proj>/node_modules/lerna/index.js:44:6)
    at Object.<anonymous> (<proj>/node_modules/lerna/cli.js:11:15)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Thanks @Robinnnnn Downgrading to 3.17.0 and pinning the same in package.json solves the issue for me

Same here. can someone sugest a workaround here ? Our builds are failing. Downgrading to version 3.17 also didnt work