Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lettenj61 opened this issue Jul 1, 2020 · 3 comments

Comments

@lettenj61
Copy link

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 gitbook-plugin-elm-repl@1.0.0 No repository field.
npm WARN gitbook-plugin-elm-repl@1.0.0 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 gitbook-plugin-elm-repl@1.0.0 No repository field.
npm WARN gitbook-plugin-elm-repl@1.0.0 No license field.

+ uglify-js@3.10.0
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 uglify-js@3.9.4
 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 uglify-js@3.10.0 --output=test.js
npx: installed 1 in 2.445s
ERROR: invalid option --output=test.js
undefined
$ echo 'module.exports = {}' | npx uglify-js@3.9.4 --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.

@rafaelassumpcao
Copy link

hey @lettenj61 I have found the same issue on my way, and you are right the uglify CLI API have changed at version 3+ as you can see here

and as you have suggested, this is the fix for the version simply removing the '=' sign
did you open a PR? I couldn't find it. to link here.

lettenj61 added a commit to lettenj61/guide.elm-lang.org that referenced this issue Jul 20, 2020
* This patch was originally written for `elm-jp/guide` by @negiboudu san
@lettenj61
Copy link
Author

lettenj61 commented Jul 20, 2020

@rafaelassumpcao No, I was too lazy to create PR and just posted my workaround 😉
Opened one so that anyone can refer to it (#252)

I must mention that the PR is based on the patch @negiboudu san compiled for our Japanese translation (repo).

@evancz
Copy link
Owner

evancz commented Feb 10, 2021

I recently merged #258 which should fix this!

@evancz evancz closed this as completed Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants