Skip to content

Build fails with ERROR: invalid option --output=assets/repl.js when using uglify-js >= 3.10.0 #251

Closed
@lettenj61

Description

@lettenj61

Please fill in the following information:

  • My programming background is ...
    • Maintain enterprise web (both backend and frontend) with Java, JavaScript, and bare HTML/CSS for 6+ yrs. Using Elm for about 12 months personally
  • I want to learn Elm because ...
    • I love its concept, and performance too! I can code with joy when I use Elm. I also make small commit on Japanese translation of the guide. Thanks so much for your great creation and sharings!
  • I was confused by ...
    • It is not about content but the build process.

Hello,

Recently I've encountered an error after I cloned this repository and run build.sh at first time. Here is the outcome:

wsl@machine:~/ghq/github.com/evancz/guide.elm-lang.org$ bash ./build.sh
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

up to date in 0.584s
found 0 vulnerabilities

/home/wsl/.nvm/versions/node/v14.5.0/lib/node_modules/gitbook-plugin-elm-repl -> /home/wsl/ghq/github.com/evancz/guide.elm-lang.org/repl
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   635  100   635    0     0    785      0 --:--:-- --:--:-- --:--:--   785
100 6647k  100 6647k    0     0   229k      0  0:00:28  0:00:28 --:--:--  472k
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

+ [email protected]
added 1 package from 1 contributor and audited 1 package in 2.22s
found 0 vulnerabilities

Starting downloads...

  ● elm/http 2.0.0
  ● elm/json 1.1.3
  ● elm/virtual-dom 1.0.2
  ● elm/core 1.0.2
  ● elm/url 1.0.0
  ● elm/html 1.0.0
  ● elm/project-metadata-utils 1.0.0
  ● elm/parser 1.1.0
  ● elm/time 1.0.0
  ● elm/browser 1.0.1
  ● elm/bytes 1.0.8
  ● elm/file 1.0.5

Dependencies ready!
Success! Compiled 3 modules.

    Repl ───> elm.js

ERROR: invalid option --output=assets/repl.js
events.js:291
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:156:25)
    at writeGeneric (internal/stream_base_commons.js:147:3)
    at Socket._writeGeneric (net.js:785:11)
    at Socket._write (net.js:797:8)
    at writeOrBuffer (_stream_writable.js:352:12)
    at Socket.Writable.write (_stream_writable.js:303:10)
    at print (/home/wsl/ghq/github.com/evancz/guide.elm-lang.org/repl/node_modules/uglify-js/bin/uglifyjs:511:20)
    at run (/home/wsl/ghq/github.com/evancz/guide.elm-lang.org/repl/node_modules/uglify-js/bin/uglifyjs:384:9)
    at Object.<anonymous> (/home/wsl/ghq/github.com/evancz/guide.elm-lang.org/repl/node_modules/uglify-js/bin/uglifyjs:259:5)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:100:8)
    at emitErrorCloseNT (internal/streams/destroy.js:68:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}
wsl@machine:~/ghq/github.com/evancz/guide.elm-lang.org$

I believe this was caused by recent CLI parser update in uglfy-js, which make "=" character get rejected in --output option. As a workaround, I could fix this by specifying previous version explicitly in repl/build.sh:

@@ -11,7 +11,7 @@
 if ! [ -x elm ]; then
   chmod +x elm
 fi
 if ! [ -x node_modules/.bin/uglifyjs ]; then
-  npm install uglify-js
+  npm install [email protected]
 fi

Or, simply replace --output=foo with --output foo.

And these are short tests I ran to check uglify-js behaviour has been changed:

$ echo 'module.exports = {}' | npx [email protected] --output=test.js
npx: installed 1 in 2.445s
ERROR: invalid option --output=test.js
undefined
$ echo 'module.exports = {}' | npx [email protected] --output=test.js
npx: installed 2 in 3.07s
$ ls -la
total 0
drwxrwxrwx 1 wsl wsl 4096 Jul  1 09:06 .
drwxrwxrwx 1 wsl wsl 4096 Jul  1 09:03 ..
-rw-rw-rw- 1 wsl wsl   18 Jul  1 09:06 test.js

I was wondering if you could take a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions