Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command line arguments passed to lerna npm script not working #3024

Closed
s1mrankaur opened this issue Nov 5, 2021 · 1 comment
Closed

command line arguments passed to lerna npm script not working #3024

s1mrankaur opened this issue Nov 5, 2021 · 1 comment

Comments

@s1mrankaur
Copy link

s1mrankaur commented Nov 5, 2021

In root package.json, I have:

"deploy:customStage": "./node_modules/lerna/cli.js run deploy:customStage",

In packageA/package.json I have:

"deploy:customStage": "../../node_modules/serverless/bin/serverless.js deploy -v",

From command line I execute:

npm run deploy:customStage -- -- -- '--stage simi'

Also tried with:

npm run deploy:customStage -- -- -- '--stage' 'simi'

The expectation was that the stagename simi passed through the command line will be sent to packageA/package.json script resulting in

../../node_modules/serverless/bin/serverless.js deploy -v --stage simi

However, I get the following error:

$ npm run deploy:customStage -- -- --'--stage simi'

rootproject0.1.0 deploy:customStage
./node_modules/lerna/cli.js run deploy:customStage "--" "----stage simi"

lerna notice cli v4.0.0
lerna info versioning independent
lerna info Executing command in 1 package: "npm run deploy:customStage ----stage simi"

$ npm run deploy:customStage -- -- -- '--stage simi'

./node_modules/lerna/cli.js run deploy:customStage "--" "--" "--stage simi"

lerna notice cli v4.0.0
lerna info versioning independent
lerna info Executing command in 1 package: "npm run deploy:customStage -- --stage simi"
lerna ERR! npm run deploy:customStage -- --stage simi exited 1 in 'vlncc-resources-app-config'
lerna ERR! npm run deploy:customStage -- --stage simi stdout:

> packageA@0.1.0 deploy:customStage
> ../../node_modules/serverless/bin/serverless.js deploy -v "--stage simi"

 Serverless Error ----------------------------------------

  Serverless command "deploy --stage simi" not found. Run "serverless help" for a list of all available commands.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              15.11.0
     Framework Version:         2.62.0 (local)
     Plugin Version:            5.4.7
     SDK Version:               4.3.0
     Components Version:        3.17.1

Serverless: Deprecation warnings:

"serverless" command options are expected to follow command and not be put before the command.
Starting from the next major Serverless will no longer support the latter form.
More Info: https://www.serverless.com/framework/docs/deprecations/#CLI_OPTIONS_BEFORE_COMMAND

Variables resolver reports the following resolution errors:
  - Cannot resolve variable at "provider.stage": Cannot load file from outside of a project directory (configure "projectDir" to extend project boundary)
From a next major this will be communicated with a thrown error.
Set "variablesResolutionMode: 20210326" in your service config, to adapt to new behavior now
More Info: https://www.serverless.com/framework/docs/deprecations/#NEW_VARIABLES_RESOLVER

lerna ERR! npm run deploy:customStage -- --stage simi exited 1 in 'packageA'
@JamesHenry
Copy link
Member

Hi @s1mrankaur, there are a couple of things to note:

  • ./node_modules/lerna/cli.js is definitely an unexpected usage of lerna.

Please try updating to the latest major version of lerna which released since we took over stewardship, and update your usage to be the expected lerna run.

  • Why do you have so many double dashes in your invocation?
npm run deploy:customStage -- -- -- '--stage simi'

I think you should only need two pairs of dashes before your argument, not three: 1 for npm forwarding, 1 for lerna run forwarding

P.S. I cannot comment on that library specifically as I have never used it, but I would also strongly suggest verifying that this is the intended way to invoke the serverless executable ../../node_modules/serverless/bin/serverless.js, I would imagine npx serverless would be more idiomatic

I will close this for now, but please feel free to reopen if you follow the above advice and it is still not working on the latest version

@JamesHenry JamesHenry closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants