npx <package> runs on command line but not in package.json scripts section

Viewed 2587

I have a package installed in node using npm i mypackage --save-dev and it works fine on the command line with npx mypackage --options but when I want to have it in the package.json files scripts section it it fails. I tried

"scripts": {
 "mystuff": "mypackage --options",
 "mystuffnpm": "npm run mypackage --options",
 "mystuffnpx": "npx mypackage --options"
}

but nothing works. What is the right way to get it in the scripts section running?

1 Answers
  1. After integrating any package without command try "npx run".It will install the missing packages in node modules.

  2. Make sure you are running the command in the specific directory.

  3. Try "npm init -y" to make new package.json file and then install the packages.

Related