question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

During docker build: Syntax error: "(" unexpected

See original GitHub issue

Ran into this error while running docker build for a project locally on OS X. I read in a perhaps somewhat related thread that local OS X dependencies can mix with the files that are compiled during the docker build command so I ran $ npm uninstall -g npm on my local machine. Has anyone else run into this?

[21:03:32] Using gulpfile /app/gulpfile.js [21:03:32] Starting ‘generate-assets’… [21:03:32] Starting ‘styles’… [21:03:32] Starting ‘scripts’… [21:03:32] Starting ‘vendorScripts’… [21:03:32] Starting ‘imgCompression’… [21:03:33] Finished ‘scripts’ after 303 ms [21:03:33] ‘imgCompression’ errored after 306 ms [21:03:33] Error in plugin “gulp-imagemin” Message: /app/node_modules/optipng-bin/vendor/optipng: 1: /app/node_modules/optipng-bin/vendor/optipng: Syntax error: “(” unexpected

Details: code: 2 killed: false stdout: stderr: /app/node_modules/optipng-bin/vendor/optipng: 1: /app/node_modules/optipng-bin/vendor/optipng: Syntax error: “(” unexpected

failed: true
signal: null
cmd: /app/node_modules/optipng-bin/vendor/optipng -strip all -clobber -fix -o 3 -out /tmp/d41e4654-da3c-4094-9b45-b2b08389e429 /tmp/9b181e38-4179-42c2-8c69-75bcb1320b5e
timedOut: false
fileName: /app/clientsite/static/images/clientsite_logo_500_500_red.png
domainEmitter: [object Object]
domain: [object Object]
domainThrown: false

[21:03:33] ‘generate-assets’ errored after 313 ms npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! clientsite@0.1.0 build: gulp generate-assets npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the clientsite@0.1.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2020-10-27T21_03_33_133Z-debug.log

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
drichfieldcommented, May 21, 2021

In my case it was simply because i had previously run an npm install on my local machine in the same app that I’m building the image from. The Dockerfile was setup to copy the entire repo into the image, which in my case, included node_modules. Deleting it before building the image and then adding a .dockerignore with the node_modules exclusion solves it.

0reactions
hyunhoRIDIcommented, Nov 23, 2022

In my case it was simply because i had previously run an npm install on my local machine in the same app that I’m building the image from. The Dockerfile was setup to copy the entire repo into the image, which in my case, included node_modules. Deleting it before building the image and then adding a .dockerignore with the node_modules exclusion solves it.

amazing. Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker bash: syntax error: unexpected "(" (expecting "then")
I try to run bash scripts in Docker, buit I keep getting this error: ./scripts/proto-generator.sh: line 13: syntax error: unexpected ...
Read more >
shell script error : Syntax error: "(" unexpected
The script is being executed by sh , not bash , and is choking on the function declaration syntax. – DopeGhoti. Feb 26,...
Read more >
Docker container shutting down with logs "SyntaxError
Docker container shutting down with logs "SyntaxError: Unexpected token '<'" ... So I'm new with docker and I'm running a very simple react...
Read more >
Docker Build - Error - Code with Mosh Forum
docker run hello-docker /app/app.js:1 console.log(“Hello Docker”)`;. SyntaxError: Unexpected end of input at internalCompileFunction ...
Read more >
[Solved]-Docker syntax error end of file unexpected-docker
Most of time, the error causes because you write your script on windows, the line break on windows is \r\n , while on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found