gatsby: Unknown argument: uglify

PR #4755 introduced a --no-uglify flag but it doesn’t work for me when invoked from an npm script or via npx:

$ npx gatsby build --no-uglify
node_modules\gatsby\dist\bin\gatsby.js build

Options:
  -h, --help      Show help                                                       
  --verbose       Turn on verbose output                                          
  --no-color      Turn off the color in output                                    
  --prefix-paths  Build site with link paths prefixed (set prefix in your config).
  --no-uglify     Build site without uglifying JS bundles (for debugging).        
  -v, --version   Show version number                                             

Unknown argument: uglify

As a workaround, it is possible to do

$ npx gatsby build --noUglify

or

{
  "scripts": {
    "build": "gatsby build --noUglify"
  }
}

Note: I previously made it sound like the CLI parsing is incorrect but doing $ gatsby build --no-uglify (using global gatsby-cli) works correctly. Sorry!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 29 (29 by maintainers)

Commits related to this issue

Most upvoted comments

Oh I just realized something – thanks, @pieh! An important detail in the OP, and also my miscommunication (sorry!) is that I’m actually running gatsby build from a package.json so Gatsby used is local. That probably makes a difference. These are exactly the things I can do, now:

$ npx gatsby --version
1.9.244

$ npx gatsby build --noUglify
# ... build output here ...
# it correctly builds which means that the `noUglify` parameter is understood

$ npx gatsby build --no-uglify
node_modules\gatsby\dist\bin\gatsby.js build

Options:
  -h, --help      Show help                                                                         [boolean]
  --verbose       Turn on verbose output                                           [boolean] [default: false]
  --no-color      Turn off the color in output                                     [boolean] [default: false]
  --prefix-paths  Build site with link paths prefixed (set prefix in your config). [boolean] [default: false]
  --no-uglify     Build site without uglifying JS bundles (for debugging).         [boolean] [default: false]
  -v, --version   Show version number                                                               [boolean]

Unknown argument: uglify

$ yarn run build
yarn run v1.5.1
$ gatsby build --no-uglify
node_modules\gatsby\dist\bin\gatsby.js build

Options:
  -h, --help      Show help                                                                         [boolean]
  --verbose       Turn on verbose output                                           [boolean] [default: false]
  --no-color      Turn off the color in output                                     [boolean] [default: false]
  --prefix-paths  Build site with link paths prefixed (set prefix in your config). [boolean] [default: false]
  --no-uglify     Build site without uglifying JS bundles (for debugging).         [boolean] [default: false]
  -v, --version   Show version number                                                               [boolean]

Unknown argument: uglify

Note how --noUglify works but --no-uglify doesn’t so it’s still likely a Gatsby issue, I would think.

I’m able to reproduce this on my mac if that helps:

$ yarn build
yarn run v1.6.0
$ gatsby build --no-uglify
gatsby build

Build a Gatsby project.

Options:
  --verbose       Turn on verbose output                                                        [boolean] [default: false]
  --no-color      Turn off the color in output                                                  [boolean] [default: false]
  --prefix-paths  Build site with link paths prefixed (set prefix in your config).              [boolean] [default: false]
  --no-uglify     Build site without uglifying JS bundles (for debugging).                      [boolean] [default: false]
  -h, --help      Show help                                                                                      [boolean]
  -v, --version   Show version number                                                                            [boolean]

Unknown argument: uglify

Does the same thing when run by NPM:

$ npm run build

> <project name>@0.1.0 build <project directory>
> gatsby build --no-uglify

gatsby build

Build a Gatsby project.

Options:
  --verbose       Turn on verbose output                                                        [boolean] [default: false]
  --no-color      Turn off the color in output                                                  [boolean] [default: false]
  --prefix-paths  Build site with link paths prefixed (set prefix in your config).              [boolean] [default: false]
  --no-uglify     Build site without uglifying JS bundles (for debugging).                      [boolean] [default: false]
  -h, --help      Show help                                                                                      [boolean]
  -v, --version   Show version number                                                                            [boolean]

Unknown argument: uglify
npm ERR! code ELIFECYCLE
npm ERR! errno 1

<...etc>

If there’s any info I can give you guys about my setup I’m happy to.

@borekb you can check merge commit and see tags on github - it was added in gatsby@1.9.244 and gatsby-cli@1.1.50