Permission Issue with starting react - node.js

I have an issue with web app running on react, In fact, react fail to start on browser and sone error in terminal.
Can you help please.
/app/node_modules/webpack-cli/bin/cli.js:281
node_1 | throw err;
node_1 | ^
node_1 |
node_1 | Error: EACCES: permission denied, unlink '/app/public/build/fonts/palmhr.8008cff1.ttf'
node_1 | at Object.unlinkSync (fs.js:956:3)
node_1 | at rimrafSync (/app/node_modules/rimraf/rimraf.js:314:17)
node_1 | at /app/node_modules/rimraf/rimraf.js:350:5
node_1 | at Array.forEach (<anonymous>)
node_1 | at rmkidsSync (/app/node_modules/rimraf/rimraf.js:349:26)
node_1 | at rmdirSync (/app/node_modules/rimraf/rimraf.js:342:7)

Related

Node Js app crashes after rebooting postgres server

I have :
One docker container containing a server with a node-js app.
One docker container containing a postgres database.
There is a connection between these two.
Once I reboot the Postgres server the app crashes and wont restart until I manually restart it.
I'm using pm2 to run the nodejs app and thats what I get when pm2 logs
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
/root/.pm2/pm2.log last 15 lines:
PM2 | 2021-09-22T12:58:58: PM2 log: pid=1947 msg=process killed
PM2 | 2021-09-22T12:58:58: PM2 log: App [myApp:0] starting in -fork mode-
PM2 | 2021-09-22T12:58:58: PM2 log: App [myApp:0] online
PM2 | 2021-09-22T13:00:24: PM2 log: Change detected on path package.json.989998446 for app myApp - restarting
PM2 | 2021-09-22T13:00:24: PM2 log: Stopping app:myApp id:0
PM2 | 2021-09-22T13:00:24: PM2 log: App [myApp:0] exited with code [0] via signal [SIGINT]
PM2 | 2021-09-22T13:00:24: PM2 log: pid=1955 msg=process killed
PM2 | 2021-09-22T13:00:24: PM2 log: App [myApp:0] starting in -fork mode-
PM2 | 2021-09-22T13:00:24: PM2 log: App [myApp:0] online
PM2 | 2021-09-22T13:00:25: PM2 log: Change detected on path package-lock.json.95280979 for app myApp - restarting
PM2 | 2021-09-22T13:00:25: PM2 log: Stopping app:myApp id:0
PM2 | 2021-09-22T13:00:25: PM2 log: App [myApp:0] exited with code [0] via signal [SIGINT]
PM2 | 2021-09-22T13:00:25: PM2 log: pid=2005 msg=process killed
PM2 | 2021-09-22T13:00:25: PM2 log: App [myApp:0] starting in -fork mode-
PM2 | 2021-09-22T13:00:25: PM2 log: App [myApp:0] online
/root/.pm2/logs/myApp-error.log last 15 lines:
0|myApp | at Function.Module._load (internal/modules/cjs/loader.js:708:14)
0|myApp | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
0|myApp | at internal/main/run_main_module.js:17:47
0|myApp | /home/ubuntu/Project/bootcamp-app/node_modules/postgres/lib/backend.js:177
0|myApp | if (backend.query.result.command) {
0|myApp | ^
0|myApp |
0|myApp | TypeError: Cannot read property 'result' of undefined
0|myApp | at Object.RowDescription (/home/ubuntu/Project/bootcamp-app/node_modules/postgres/lib/backend.js:177:23)
0|myApp | at Socket.data (/home/ubuntu/Project/bootcamp-app/node_modules/postgres/lib/connection.js:161:25)
0|myApp | at Socket.emit (events.js:314:20)
0|myApp | at addChunk (_stream_readable.js:297:12)
0|myApp | at readableAddChunk (_stream_readable.js:272:9)
0|myApp | at Socket.Readable.push (_stream_readable.js:213:10)
0|myApp | at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
/root/.pm2/logs/myApp-out.log last 15 lines:
0|myApp | errno: 'ECONNREFUSED',
0|myApp | code: 'ECONNREFUSED',
0|myApp | syscall: 'connect',
0|myApp | address: '**.**.***.***',//edited that for safety
0|myApp | port: 5432
0|myApp | }
0|myApp | Error: connect ECONNREFUSED **.**.***.***:5432
0|myApp | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) {
0|myApp | errno: 'ECONNREFUSED',
0|myApp | code: 'ECONNREFUSED',
0|myApp | syscall: 'connect',
0|myApp | address: '**.**.***.***',
0|myApp | port: 5432
0|myApp | }
0|myApp | [nodemon] app crashed - waiting for file changes before starting...
any suggestions?

Error: Failed to load gRPC binary module because it was not installed for the current system when trying to run from a docker container

Error: Failed to load gRPC binary module because it was not installed for the current system
api_1 | Expected directory: node-v72-linux-x64-musl
api_1 | Found: [node-v64-linux-x64-glibc, node-v72-linux-x64-glibc, node-v83-linux-x64-glibc]
api_1 | This problem can often be fixed by running "npm rebuild" on the current system
api_1 | Original error: Cannot find module '/usr/src/app/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node'
api_1 | Require stack:
api_1 | - /usr/src/app/node_modules/grpc/src/grpc_extension.js
api_1 | - /usr/src/app/node_modules/grpc/src/client_interceptors.js
api_1 | - /usr/src/app/node_modules/grpc/src/client.js
api_1 | - /usr/src/app/node_modules/grpc/index.js
api_1 | - /usr/src/app/middleware/license.js
api_1 | - /usr/src/app/app.js
api_1 | at Object.<anonymous> (/usr/src/app/node_modules/grpc/src/grpc_extension.js:53:17)
api_1 | at Module._compile (internal/modules/cjs/loader.js:1015:30)
api_1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
api_1 | at Module.load (internal/modules/cjs/loader.js:879:32)
api_1 | at Function.Module._load (internal/modules/cjs/loader.js:724:14)
api_1 | at Module.require (internal/modules/cjs/loader.js:903:19)
api_1 | at require (internal/modules/cjs/helpers.js:74:18)
api_1 | at Object.<anonymous> (/usr/src/app/node_modules/grpc/src/client_interceptors.js:144:12)
api_1 | at Module._compile (internal/modules/cjs/loader.js:1015:30)
api_1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
api_1 | at Module.load (internal/modules/cjs/loader.js:879:32)
api_1 | at Function.Module._load (internal/modules/cjs/loader.js:724:14)
api_1 | at Module.require (internal/modules/cjs/loader.js:903:19)
api_1 | at require (internal/modules/cjs/helpers.js:74:18)
api_1 | at Object.<anonymous> (/usr/src/app/node_modules/grpc/src/client.js:35:27)
api_1 | at Module._compile (internal/modules/cjs/loader.js:1015:30) {
api_1 | code: 'MODULE_NOT_FOUND'
api_1 | }
i am trying to run from inside a docker container i tried changing the node version but still cant solve it i tried node v 12 and 14
had the same problem, this fixed it
npm install --target=12.0.0 --target_platform=linux --target_arch=x64 --target_libc=musl

pm2 logs error port:3000 please fix this error

/Users/jake/.pm2/logs/main-error.log last 15 lines:
0|main | at listenInCluster (net.js:1356:12)
0|main | at Server.listen (net.js:1444:7)
0|main | at Object.<anonymous> (/Users/jake/Desktop/Nodejs-master/main.js:143:5)
0|main | at Module._compile (internal/modules/cjs/loader.js:1139:30)
0|main | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
0|main | at Module.load (internal/modules/cjs/loader.js:988:32)
0|main | at Function.Module._load (internal/modules/cjs/loader.js:896:14)
0|main | at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:32:23)
0|main | at Module._compile (internal/modules/cjs/loader.js:1139:30) {
0|main | code: 'EADDRINUSE',
0|main | errno: -48,
0|main | syscall: 'listen',
0|main | address: '::',
0|main | port: 3000
0|main | }
pm2 start main.js --watch works but when i try pm2 logs i got above error
anyone please help to fix this error thanks
EADDRINUSE means this port is already being used by some other application. Maybe a node is already running on this port.
First, run sudo pkill -9 node and use pm2. If this doesn't solve your problem, then ->
kill -9 $(sudo lsof -t -i:3000)

not able to dockerize node.js application

not able to create docker image for node.js app
getting ReferenceError: load_fonts is not defined:
WARNING: Some services (app) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.
Starting appdc_app_1 ... done
Attaching to appdc_app_1
app_1 |
app_1 | > express-docker-app#1.0.0 start /usr/src/app
app_1 | > node app.js
app_1 |
app_1 | /usr/src/app/app.js:806
app_1 | load_fonts({
app_1 | ^
app_1 |
app_1 | ReferenceError: load_fonts is not defined
app_1 | at Object.<anonymous> (/usr/src/app/app.js:806:1)
app_1 | at Module._compile (internal/modules/cjs/loader.js:936:30)
app_1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
app_1 | at Module.load (internal/modules/cjs/loader.js:790:32)
app_1 | at Function.Module._load (internal/modules/cjs/loader.js:703:12)
app_1 | at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
app_1 | at internal/main/run_main_module.js:17:11
app_1 | npm ERR! code ELIFECYCLE

Database connection errors with docker-compose POSTGRES & SEQUELIZE

I have a node app that uses postgres and sequelize. I have a docker file that will run my server. I also have a docker compose file that will run a web image and db image that link my docker images and connect them together.
I am able to get my server running thorugh the docker file. I am trying to use the docker-compose file to run the database with it and and get them to work. I am getting a connection error with the database that is trying to connect and I am not sure where this error is coming from...
Dockerfile
FROM node:10
WORKDIR /app
COPY package.json ./app
RUN npm install
COPY . /app
CMD npm start
EXPOSE 5585
dock compose file:
version: "2"
services:
web:
build: .
ports:
- 80:5585
command: npm start
depends_on:
- db
environment:
- DATABASE_URL=postgres://username:password#db:5432/addidas
db:
image: postgres
restart: always
ports:
- "5432:5432"
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=addidas
I am also using sequelize to connect my database with express. Do i need to change anythign to do that.
ERROR:
web_1 | Fri, 09 Nov 2018 18:26:47 GMT sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators at node_modules/sequelize/lib/sequelize.js:242:13
web_1 | server is running at http://localhost:3001
web_1 | { SequelizeConnectionRefusedError: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at connection.connect.err (/app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:116:24)
web_1 | at Connection.connectingErrorHandler (/app/node_modules/pg/lib/client.js:140:14)
web_1 | at Connection.emit (events.js:182:13)
web_1 | at Socket.reportStreamError (/app/node_modules/pg/lib/connection.js:71:10)
web_1 | at Socket.emit (events.js:182:13)
web_1 | at emitErrorNT (internal/streams/destroy.js:82:8)
web_1 | at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
web_1 | at process._tickCallback (internal/process/next_tick.js:63:19)
web_1 | name: 'SequelizeConnectionRefusedError',
web_1 | parent:
web_1 | { Error: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
web_1 | errno: 'ECONNREFUSED',
web_1 | code: 'ECONNREFUSED',
web_1 | syscall: 'connect',
web_1 | address: '172.19.0.3',
web_1 | port: 5432 },
web_1 | original:
web_1 | { Error: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
web_1 | errno: 'ECONNREFUSED',
web_1 | code: 'ECONNREFUSED',
web_1 | syscall: 'connect',
web_1 | address: '172.19.0.3',
web_1 | port: 5432 } }
web_1 | { SequelizeConnectionRefusedError: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at connection.connect.err (/app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:116:24)
web_1 | at Connection.connectingErrorHandler (/app/node_modules/pg/lib/client.js:140:14)
web_1 | at Connection.emit (events.js:182:13)
web_1 | at Socket.reportStreamError (/app/node_modules/pg/lib/connection.js:71:10)
web_1 | at Socket.emit (events.js:182:13)
web_1 | at emitErrorNT (internal/streams/destroy.js:82:8)
web_1 | at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
web_1 | at process._tickCallback (internal/process/next_tick.js:63:19)
web_1 | name: 'SequelizeConnectionRefusedError',
web_1 | parent:
web_1 | { Error: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
web_1 | errno: 'ECONNREFUSED',
web_1 | code: 'ECONNREFUSED',
web_1 | syscall: 'connect',
web_1 | address: '172.19.0.3',
web_1 | port: 5432 },
web_1 | original:
web_1 | { Error: connect ECONNREFUSED 172.19.0.3:5432
web_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
web_1 | errno: 'ECONNREFUSED',
web_1 | code: 'ECONNREFUSED',
web_1 | syscall: 'connect',
web_1 | address: '172.19.0.3',
web_1 | port: 5432 } }
1st change to 5432 to defalut postgres port
db:
image: postgres
restart: always
ports:
- "5432:3306" //default postgres port
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=addidas
Allow the port you want to connect
sudo ufw allow 5432
try:
...
web:
build:
context: .
ports:
- 80:5585
command: npm start
network_mode: service:db
links:
- db
environment:
- DATABASE_URL=postgres://username:password#db:5432/addidas
...
Another thing is that from the expose line I guess that you want to run the node app on port 5585. But it is actually running on port 3001 (Based on the 2. line of the error message)

Resources