I am trying to run a nuxtjs app using pm2 however, the app exits immediately, and I could not get useful info from pm2 log:
2|frontend_nuxt | Error: ENOENT: no such file or directory, chdir '����' -> '/var/www/frontend_nuxt/releases/20210831071742'
2|frontend_nuxt | at wrappedChdir (node:internal/bootstrap/switches/does_own_process_state:112:14)
2|frontend_nuxt | at process.chdir (node:internal/worker:100:5)
2|frontend_nuxt | at /usr/local/share/.config/yarn/global/node_modules/pm2/lib/ProcessContainer.js:298:13
2|frontend_nuxt | at wrapper (/usr/local/share/.config/yarn/global/node_modules/pm2/node_modules/async/internal/once.js:12:16)
2|frontend_nuxt | at next (/usr/local/share/.config/yarn/global/node_modules/pm2/node_modules/async/waterfall.js:96:20)
2|frontend_nuxt | at /usr/local/share/.config/yarn/global/node_modules/pm2/node_modules/async/internal/onlyOnce.js:12:16
2|frontend_nuxt | at WriteStream.<anonymous> (/usr/local/share/.config/yarn/global/node_modules/pm2/lib/Utility.js:186:13)
2|frontend_nuxt | at WriteStream.emit (node:events:394:28)
2|frontend_nuxt | at node:internal/fs/streams:72:16
2|frontend_nuxt | at FSReqCallback.oncomplete (node:fs:185:23)
The nuxtjs app it self can start without issue.
I have no idea how to debug this error, or how to get more useful details, any idea?
using npm2 show id I found that the script path was not updated.
so, i just had to:
pm2 delete frontend_nuxt && pm2 start ecosystem.config.js
and all is well.
Related
I have node application that build into an image. This image not contain .env file because I add it on .gitignore whereas the application need it. How can I configure this environment on docker-compose?
I've read some of example but still dont get it. This question has same problem with me but it still doesn't work.
docker-compose:
version: "3.7"
services:
node:
container_name: node-app
image: node_app:latest
ports:
- 3334:3333
environment:
- HOST=127.0.0.1
- PORT=3333
- NODE_ENV=dummy
- APP_NAME=AdonisJs
- CACHE_VIEWS=false
- DB_CONNECTION=mysql
- DB_HOST=127.0.0.1
- DB_PORT=3306
- DB_USER=root
- DB_PASSWORD=password
- DB_DATABASE=database
Dockerfile:
FROM node:14
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm i -g #adonisjs/cli
RUN npm install
ENV HOST=0.0.0.0
COPY . .
EXPOSE 3333
CMD [ "node", "server.js" ]
Everytime I run docker-compose up its ended up with this.
WARNING: The HOST variable is not set. Defaulting to a blank string.
WARNING: The PORT variable is not set. Defaulting to a blank string.
Recreating node-app_node_1 ... done
Attaching to node-app_node_1
node_1 |
node_1 | Error: ENOENT: no such file or directory, open '/usr/src/app/.env'
node_1 |
node_1 |
node_1 | 1 Env.load
node_1 | /usr/src/app/node_modules/#adonisjs/framework/src/Env/index.js:110
node_1 |
node_1 | 2 new Env
node_1 | /usr/src/app/node_modules/#adonisjs/framework/src/Env/index.js:42
node_1 |
node_1 | 3 Object.closure
node_1 | /usr/src/app/node_modules/#adonisjs/framework/providers/AppProvider.js:29
node_1 |
node_1 | 4 Ioc._resolveBinding
node_1 | /usr/src/app/node_modules/#adonisjs/fold/src/Ioc/index.js:231
node_1 |
node_1 | 5 Ioc.use
node_1 | /usr/src/app/node_modules/#adonisjs/fold/src/Ioc/index.js:731
node_1 |
node_1 | 6 AppProvider.boot
node_1 | /usr/src/app/node_modules/#adonisjs/framework/providers/AppProvider.js:337
node_1 |
node_1 | 7 anonymous
node_1 | /usr/src/app/node_modules/#adonisjs/fold/src/Registrar/index.js:147
node_1 |
node_1 | 8 arrayMap
node_1 | /usr/src/app/node_modules/lodash/lodash.js:653
node_1 |
node-app_node_1 exited with code 1
All I know that docker-compose environment pass to the variable that called just as same as we define to get the value, but there is not .env file on the image to called the variable. What I have to do to make the docker-compose can pass the environment to the app? Any suggestion will be appreciated.
ENOENT indicates that node is looking for a file at /usr/src/app/.env but there is nothing there. Try adding
RUN touch /usr/src/app/.env
to your Dockerfile and see if having an empty .env file fixes it.
I am trying to build a Docker image for my Sails.js application. Here's the Dockerfile:
FROM risingstack/alpine:3.4-v8.5.0-4.7.0
ENV NODE_ENV test
RUN npm install -g sails
COPY npmrc_file .npmrc
ARG NPM_TOKEN
COPY package.json package.json
RUN npm install
RUN rm -f .npmrc
# Add your source files
COPY . .
EXPOSE 3000
CMD ["npm","start"]
I took the steps for this Dockerfile from this link on the NPM documentation site. I have made sure to match what the documentation there shows perfectly.
My docker build command is:
image="my-repo-url/tagname:tagversion"
docker build --build-arg NPM_TOKEN=my-token-goes-here -t $image -f Dockerfile .
Then I run the container with the image using docker stack or docker-compose. The container doesn't start up, due to the following error:
sails_1 | Error: Failed to replace env in config: ${NPM_TOKEN}
sails_1 | at /usr/lib/node_modules/npm/lib/config/core.js:418:13
sails_1 | at String.replace (<anonymous>)
sails_1 | at envReplace (/usr/lib/node_modules/npm/lib/config/core.js:414:12)
sails_1 | at parseField (/usr/lib/node_modules/npm/lib/config/core.js:392:7)
sails_1 | at /usr/lib/node_modules/npm/lib/config/core.js:335:17
sails_1 | at Array.forEach (<anonymous>)
sails_1 | at Conf.add (/usr/lib/node_modules/npm/lib/config/core.js:334:23)
sails_1 | at ConfigChain.addString (/usr/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
sails_1 | at Conf.<anonymous> (/usr/lib/node_modules/npm/lib/config/core.js:322:10)
sails_1 | at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
sails_1 | /usr/lib/node_modules/npm/lib/npm.js:52
sails_1 | throw new Error('npm.load() required')
sails_1 | ^
sails_1 |
sails_1 | Error: npm.load() required
sails_1 | at Object.get (/usr/lib/node_modules/npm/lib/npm.js:52:13)
sails_1 | at process.errorHandler (/usr/lib/node_modules/npm/lib/utils/error-handler.js:213:18)
sails_1 | at emitOne (events.js:115:13)
sails_1 | at process.emit (events.js:210:7)
sails_1 | at process._fatalException (bootstrap_node.js:399:26)
The thing is, by the time we get to running the container, there should be no reference to or need for the ${NPM_TOKEN}. I'm using this exact same setup in another project, and don't see this error, so I'm not really sure what the deal is. I have triple checked that everything is the same in this project as the other project.
What are the possible reasons for this error and some possible solutions?
I've also read through this thread and this SO question. I feel like everything I've read has pointed me to the same solution, which I've implemented, but with no success.
This is what worked for me in the end:
ARG NPM_TOKEN
ENV NPM_TOKEN="${NPM_TOKEN}"
Why this solved this issue, I'm not sure!
This is what I am using,
in Dockerfile
ARG NPM_AUTH_TOKEN=$NPM_AUTH_TOKEN
ENV NPM_AUTH_TOKEN=$NPM_AUTH_TOKEN
and in docker-compose.yml
version: '2'
services:
app:
build:
args:
- NPM_AUTH_TOKEN
I am using sane-cli in an ember app and when I try to use sane up inside the sails folder. I am getting this error. Can anyone help me to fix it?
I have already tried sudo npm install inside the server folder and globally.
Error log (image):
client | Could not start watchman
client | was unable to use: "events", fell back to: "polling"
server | debug: initializing sails-hook-dev...
server | events.js:160
server | throw er; // Unhandled 'error' event
server | ^
server |
server | Error: watch /home/ayush/Code/sails/server/api/blueprints EPERM
server | at exports._errnoException (util.js:1018:11)
server | at FSWatcher.start (fs.js:1443:19)
server | at Object.fs.watch (fs.js:1470:11)
server | at createFsWatchInstance
(/home/ayush/Code/sails/server/node_modules/chokidar/lib/nodefs-
handler.js:37:15)
server | at setFsWatchListener
(/home/ayush/Code/sails/server/node_modules/chokidar/lib/nodefs-
handler.js:80:15)
server | at FSWatcher.NodeFsHandler._watchWithNodeFs
(/home/ayush/Code/sails/server/node_modules/chokidar/lib/nodefs-
handler.js:228:14)
server | at FSWatcher.NodeFsHandler._handleDir
(/home/ayush/Code/sails/server/node_modules/chokidar/lib/nodefs-
handler.js:407:19)
server | at FSWatcher.<anonymous>
(/home/ayush/Code/sails/server/node_modules/chokidar/lib/nodefs-
handler.js:455:19)
server | at FSWatcher.<anonymous>
(/home/ayush/Code/sails/server/node_modules/chokidar/lib/nodefs-
handler.js:460:16)
server | at FSReqWrap.oncomplete (fs.js:123:15)
client | Proxying to http://127.0.0.1:1337
client | Livereload server on http ://localhost:49153
client | Serving on http ://localhost:4200/
I'm attempting to use the postgres add-on with a heroku node app that is also using react.
I'm using this react buildpack to support react inside heroku:
https://github.com/opike/create-react-app-buildpack.git
When I try to add the line:
var pg = require('pg');
I get the following compilation error when I try to run the heroku app locally:
>heroku local web
[OKAY] Loaded ENV .env File as KEY=VALUE Format
[WARN] ENOENT: no such file or directory, open 'Procfile'
[OKAY] package.json file found - trying 'npm start'
4:15:19 PM web.1 | > test-app#0.1.0 start /Users/oliverpike/dev/heroku/ofp-react
4:15:19 PM web.1 | > react-scripts start
4:15:20 PM web.1 | Starting the development server...
4:15:29 PM web.1 | Failed to compile.
4:15:29 PM web.1 | Error in ./~/pg/lib/native/index.js
4:15:29 PM web.1 | Module not found: 'pg-native' in /Users/oliverpike/dev/heroku/ofp-react/node_modules/pg/lib/native
4:15:29 PM web.1 | # ./~/pg/lib/native/index.js 1:13-33
4:15:29 PM web.1 | Error in ./~/pg/lib/connection-parameters.js
4:15:29 PM web.1 | Module not found: 'dns' in /Users/oliverpike/dev/heroku/ofp-react/node_modules/pg/lib
4:15:29 PM web.1 | # ./~/pg/lib/connection-parameters.js 2:10-24
I was able to get past this issue by doing an:
> npm i pg-native
as described here:
https://github.com/brianc/node-pg-native
as well as an
> npm i dns
for the dns issue.
The odd thing was that I didn't need to explicitly install these packages in my other heroku app that is using postgres.
I'm running three node.js applications on one server, all using Foreman to start up the apps through always.js.
Under zero load, one of my apps consistently throws the error Error: watch EMFILE and restarts. That application still works though, despite constantly throwing that error... I've tried to find more information about this error, but there's not a whole lot out there ("too many files open" or "increase ulimit".)
My question is: why would this be happening on an idle web application - and why just one out of three? It's not doing anything... Is it an issue with always.js? (There are two other node apps running through always on this machine though...) Just looking for some info as to what is causing this error, if it's serious, and how it can be resolved.
Thanks!
FYI, here is a relevant excerpt from the console:
01:17:07 web.1 | app listening on http://0.0.0.0:5000
01:17:07 web.1 | NODE_ENV = development
01:17:07 web.1 | opened connection to database!
01:17:07 web.1 | [always] Error: watch EMFILE
01:17:07 web.1 | [always] Error: watch EMFILE
01:17:07 web.1 | at errnoException (fs.js:636:11)
01:17:07 web.1 | at FSWatcher.start (fs.js:663:11)
01:17:07 web.1 | at Object.watch (fs.js:691:11)
01:17:07 web.1 | at Object.oncomplete (/home/jesse/local/nodev0.6.14/lib/node_modules/always/lib/monitor.js:62:36)
01:17:07 web.1 | [always] Restarting app.js with Node
I don't have experience with always.js but got similar errors with other node utilities that use the fs.watch command, which in turn uses linux's inotify API.
You might want to try checking the settings for inotify then:
cat /proc/sys/fs/inotify/max_user_instances
If the file exists, setting it to a higher value might help:
echo 8704 > /proc/sys/fs/inotify/max_user_instances