I learn React and try to run an app. When I start the app in terminal, it goes nice and works as expected, but when I do the very same thing in container it fails. Here are the details:
root@b8457ff69aac:/app# node -v
v16.17.0
root@b8457ff69aac:/app# npm -v
8.15.0
The error:
root@b8457ff69aac:/app# npm start server
> voting_app@1.1.0 start
> npm run server
> voting_app@1.1.0 server
> live-server public --host=localhost --port=9001 --middleware=./disable-browser-cache.js
(node:134) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Serving "public" at http://localhost:9001 (http://127.0.0.1:9001)
/app/node_modules/opn/index.js:82
reject(new Error('Exited with code ' + code));
^
Error: Exited with code 3
at ChildProcess.<anonymous> (/app/node_modules/opn/index.js:82:13)
at Object.onceWrapper (node:events:628:26)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1093:16)
at Socket.<anonymous> (node:internal/child_process:451:11)
at Socket.emit (node:events:513:28)
at Pipe.<anonymous> (node:net:757:14)
Dockerfile
FROM node:16.17.0
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 9001
# for sake of debug
CMD [ "sleep" , "infinity" ]
And running it:
docker run -p 9001:9001 vote-app:test2