question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

incompatibility with "npm run" and extra arguments

See original GitHub issue

If I have a script like "compile": "tsup ./app/cli.ts ./app/index.ts --metafile" and want to pass in more args I can’t via the npm run command.

When passing in more args via npm run compile -- --external=@vmngr/libvir they’re ignored since they’re passed in quoted.

❯ npm run compile -- --external=@vmngr/libvir

> @unraid/api@2.41.1 compile C:\Users\xo\code\unraid\api
> tsup ./app/cli.ts ./app/index.ts --metafile "--external=@vmngr/libvir"

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
HyperCrowdcommented, Jun 11, 2022

To add to the pain, if this was in an npm script for dev:

tsup-node --onSuccess 'node -r source-map-support/register dist/index.js'

It obviously would have no way to pass dynamic CLI commands for commanderjs or yargs via npm run dev -- someArg

It works if you hard code the args:

tsup-node --onSuccess 'node -r source-map-support/register dist/index.js someArg'

But that makes CLI testing a minor inconvenience

0reactions
OmgImAlexiscommented, Mar 11, 2022
❯ npm run compile -- --external @vmngr/libvir

> @unraid/api@2.42.1 compile C:\Users\xo\code\unraid\api
> tsup --metafile "--external" "@vmngr/libvir"

CLI Building entry: {"cli":"app/cli.ts","index":"app/index.ts"}
CLI Using tsconfig: tsconfig.json
CLI tsup v5.12.1
CLI Using tsup config: C:\Users\xo\code\unraid\api\package.json
CLI Target: node12
CJS Build start
✘ [ERROR] Could not resolve "@vmngr/libvirt"

    app/core/utils/vms/get-hypervisor.ts:8:55:
      8 │ import { ConnectListAllDomainsFlags, Hypervisor } from '@vmngr/libvirt';
        ╵                                                        ~~~~~~~~~~~~~~~~

  You can mark the path "@vmngr/libvirt" as external to exclude it from the bundle, which will
  remove this error.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass command line args to npm scripts in package.json
Firstly runs npm run vumper <arg> . Whereby <arg> will be the shell argument passed via the CLI. It is referenced in the...
Read more >
npx - npm Docs
Run a command from a local or remote npm package. ... affordances to maintain backwards compatibility with the arguments it accepted in previous...
Read more >
Manage npm packages - Visual Studio (Windows)
For more information, package.json configuration. Right-click a package node to take one of the following actions: Install npm Package(s) Runs ...
Read more >
Ubuntu Manpage: npm-exec - Run a command from a local or ...
To run a binary other than the named binary, specify one or more --package ... In contrast, due to npm's argument parsing logic,...
Read more >
Mocha - the fun, simple, flexible JavaScript test framework
Mocha is a feature-rich JavaScript test framework running on Node.js and in the ... Error Codes; Editor Plugins; Examples; Testing Mocha; More Information ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found