12

npx used to have a --node-arg option to specify options for node. In npm v7, this results in:

npx: the --n argument has been removed.
See `npm help exec` for more information

Which states:

The --node-arg and -n options are removed.

Without any information being supplied about their replacement. This is not helpful.

I have tried using --. For example to run npx jest -t 'API work' with a node option of -r:

npx -r dotenv/config dotenv_config_path=/home/mike/Code/myapp/.env.local -- jest -t 'API works'

However this doesn't do anything.

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
  • 3
    See comment at the bottom of the page [here](https://github.com/npm/npx/issues/5) - it suggests using `--node-options` instead. – RobC Mar 03 '21 at 15:52

1 Answers1

13

I just wanted to shout out RobC's Answer in the comments, as it did work for me. --node-arg has been replaced by --node-options. For example, with Fastify and Typescript:

// package.json
  "scripts": {
    ...
    "dev": "npx --node-options='-r dotenv/config' tsnd --respawn src/index.ts",
    ...
  },

Make sure to wrap all of your commands together in single quotes ('') if you're using it in a package.json!

Joe Sadoski
  • 586
  • 2
  • 7
  • 22