npm-run-all icon indicating copy to clipboard operation
npm-run-all copied to clipboard

How to run scripts like "next dev" (Next.js)?

Open jasonkylefrank opened this issue 2 years ago • 2 comments

Hello!

I'm trying to use this library to run multiple commands in parallel. One of the npm scripts that my package.json currently has is like:

"dev": "next dev"

...where next refers to Next.js and their build scripts. "next" is not an npm script listed in my package.json but it works fine somehow (it gets set up after you start your project via npx create-next-app).

I want to turn the dev npm script into:

"dev": "npm-run-all --parallel firebase-emulate  'next dev'"

...where firebase-emulate refers to another one of my npm scripts and next dev would run Next.js's build scripts as it does when that part is it's own "value" of one of the npm scripts, as shown in the earlier snippet.

As I have it written, this does not work.

Is there a way to use this library to run the dev command that I want without having to make the next dev an explicit npm script? I would rather not have to make the built-in Next.js build scripts their own npm scripts since it would litter-up my npm scripts with dedicated scripts that we would not actually run on an individual basis.

jasonkylefrank avatar Feb 28 '22 18:02 jasonkylefrank

I think a way you can make this work, is by doing something like this:

{
    "scripts": {
        "dev": "run-p dev:*",
        "dev:firebase": "firebase-emulate",
        "dev:next": "next dev"
    }
}

now when you use npm run dev it should work.

ulisses-cruz avatar Mar 11 '22 10:03 ulisses-cruz

@ulisses-cruz Yes, as I mentioned that would work but the point of my question is to find out if there is a way to do it without having to make an explicit npm script for each such script. 😀

jasonkylefrank avatar Mar 11 '22 14:03 jasonkylefrank