Docker error SyntaxError: Unexpected token ; (and my suggested fix)
westrany opened this issue · comments
Describe the bug
I wanted to use your template to create my own portofolio.
Upon trying to run the docker image, I kept getting a "docker error SyntaxError: Unexpected token ;" which I tried fixing by reviewing error message, checking for syntax issues and dependencies version compatability issues, updating npm and other dependencies, uninstalling and reinstalling npm, troubleshooting the docker image build, and reinstalling node.js and npm.
I'm not sure if the issue at hand was caused by something else on my computer, or if it has to do wish some dependency update that's causing this even though all dependencies seem compatible.
Steps to reproduce
In my case:
- Clone this repository.
- Build docker image.
- Run docker image - that's where I'd get the syntax error.
Again, unsure if this was due to something else going on on my computer, or if this was due to compatability issues.
Expected behavior
- Docker iamge would exit immediatly.
- Image wouldn't build.
- I'd get a "Docker error SyntaxError: Unexpected token ;" as shown bellow:
2023-08-21 05:18:36
2023-08-21 05:18:36 > developerfolio@0.1.0 start /app
2023-08-21 05:18:36 > node fetch.js && react-scripts start
2023-08-21 05:18:36
2023-08-21 05:18:36 /app/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110
2023-08-21 05:18:36 _ending;
2023-08-21 05:18:36 ^
2023-08-21 05:18:36
2023-08-21 05:18:36 SyntaxError: Unexpected token ;
2023-08-21 05:18:36 at Module._compile (internal/modules/cjs/loader.js:721:23)
2023-08-21 05:18:36 at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2023-08-21 05:18:36 at Module.load (internal/modules/cjs/loader.js:653:32)
2023-08-21 05:18:36 at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2023-08-21 05:18:36 at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2023-08-21 05:18:36 at Module.require (internal/modules/cjs/loader.js:690:17)
2023-08-21 05:18:36 at require (internal/modules/cjs/helpers.js:25:18)
2023-08-21 05:18:36 at Object.<anonymous> (/app/node_modules/eslint-webpack-plugin/dist/getESLint.js:9:5)
2023-08-21 05:18:36 at Module._compile (internal/modules/cjs/loader.js:776:30)
2023-08-21 05:18:36 at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2023-08-21 05:18:36 npm ERR! code ELIFECYCLE
2023-08-21 05:18:36 npm ERR! errno 1
2023-08-21 05:18:36 npm ERR! developerfolio@0.1.0 start: `node fetch.js && react-scripts start`
2023-08-21 05:18:36 npm ERR! Exit status 1
2023-08-21 05:18:36 npm ERR!
2023-08-21 05:18:36 npm ERR! Failed at the developerfolio@0.1.0 start script.
2023-08-21 05:18:36 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2023-08-21 05:18:36
2023-08-21 05:18:36 npm ERR! A complete log of this run can be found in:
2023-08-21 05:18:36 npm ERR! /root/.npm/_logs/2023-08-21T04_18_36_896Z-debug.log
Is this responsiveness Issue
NO
Screenshots
No response
Desktop
- OS: Windows 11
- Browser: OperaGX, Microsoft Edge, Brave
Smartphones
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context
After trying a bunch of different things, I managed to get the image running by modifying lines 4 and 14 of the "Dockerfile" (in the root of the repository).
Modified line 4:
FROM node:14-alpine
Modified line 14:
RUN apk update && apk add --no-cache git
I'm unsure if this will only work for me or if this could be suggested as a possible fix. Thought I'd share this just in case.
Step1: Could you remove the package-lock.json file and then try? The problem is you have the latest node version and that package-lock.json file is built using the older node version.
Step2: try the version node:14
- Also there are some known issues related to docker which I am fixing.
Here is the pull request you can use for reference:-
#628
I'll give that a try and I'll let you know it it works.
Got both docker build and image build working by changing line 14 in "Dockerfile" to RUN apk update && apk add --no-cache git
.
Dunno why this is the only thing working for me, migth be due to something else I've installed?
Thanks for your help though!
sorry for the delay, in the attached pull request, I have updated the docker file, kindly use that docker file and nginx.conf file for your work, but its fine, if things work for you.