How do I use --node-arg in npx / npm version 7?

Solution 1:

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!