I have pdfjs installed running on node.js started with nohup. I am able to start node fine and port 81 is open in the firewall. As soon as I attempt to go to it in the browser it logs the following error in the nohup.out log and node.js stops. The crazy bit is that I have this working on a temporary server that was created from an image of this one to insulate the live server while a worked all this out. Now I can't seem to replicate the success I had. I can supply the code from specific files if it would be helpful, just let me know which ones.
Server running at http://mydomain.com:81/
fs.js:186
throw new Error('Unknown file open flag: ' + flag);
^
Error: Unknown file open flag: rs
at stringToFlags (fs.js:186:13)
at Object.open (fs.js:224:44)
at new <anonymous> (fs.js:1062:6)
at Object.createReadStream (fs.js:1010:10)
at serveRequestedFile (/var/path/to/tools/pdfjs/test/webserver.js:211:23)
at Object.statFile [as oncomplete] (/var/path/to/tools/pdfjs/test/webserver.js:157:7)
Solved: Reinstalling node.js was the solution. If people encounter this error, it is likely that node either isn't installed or wasn't installed successfully. Try installing/reinstalling to correct.
Related
I'm building an E-commerce site, where there's an Authentication system.
I noticed that if the client login with a wrong user or password, the backend/server that works with nodemon will crach and hang in there crashed till i restart manually nodemon. This is example output error of the nodemon crash:
[nodemon] app crashed - waiting for file changes before starting...
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent
to the client
Ofcourse, when server crashes, client can no more access or do login again till server restarts.
After some googling, i found this question and this repository that fix my problem but particulary and not as expected precisely, i dont want nodemon to restart forever on any error that occure ofcourse, but only with specifics errors that i set them -like Authentication errors as i mentionned above-.
So, my idea/question is: is there anyway to get nodemon restarts by itself in some cases of failures or errors (NOT ALL)?
Seems like you a referring to a production situation, and nodemon is a development node server, which is not intended for use in production, as the intro states:
nodemon is a tool that helps develop Node.js based applications by
automatically restarting the node application when file changes in the
directory are detected.
You should use node.js in production, instead of nodemon.
For managing your node server in production, you could use a process manager like PM2..
That said, an authentication server that crashes every time a user uses a wrong password seams very ineffective in handling a common use case. So I would advise to start with fixing the root cause, which is the buggy server, and then for recovery from incidental crashes use something like PM2.
PS:
The error you are getting looks like an express error you get when you send a response (in this case an error response) without exiting the function e.g. by using return. Because you are not returning, another res.send is called, which causes the 'ERR_HTTP_HEADERS_SENT' error. See this answer.
This is really bad since it can send your program into a loop of restarting, but if you really want it, replace app.js with your file's name and try this:
nodemon -x 'node app.js || copy /b app.js +,,'
Linux version:
nodemon -x 'node app.js || touch app.js'
Next time try a little googleing before you ask since it is most likely faster.
So fetch-mock-jest is based on fetch-mock (it's not jest-fetch-mock..)
https://www.npmjs.com/package/fetch-mock-jest
http://www.wheresrhys.co.uk/fetch-mock/
The problem I have is:
// inside my test file
fetchMock.restore().mock('https://someSiteOnTheInternet.com', someResponse)
// inside my tested file
fetch('https://someSiteOnTheInternet.com').then(...)
The above is working but as soon as I try a local route it's not working anymore
// inside my test file
fetchMock.restore().mock('/myProxy', someResponse)
// inside my tested file
fetch('/myProxy').then(...)
This one ('/myProxy') will fail with the error :
console.error node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/virtual-console.js:29
Error: Error: connect ECONNREFUSED 127.0.0.1:80
Any idea what am I doing wrong here ?
you can set DEBUG=fetch-mock* before running your tests and that will give a lot of output to show what's going on in fetch-mock's internals.
You may have a conflict with docker,
is your front dockerized?
do you have docker running for your back-end?
can you stop docker/restart your machine and try running only your front without docker?
I am using Ubuntu 16.04 x 64 and I'm running into an issue -
When I run my Keystone JS app manually by typing in "node keystone", the app runs fine and I can view it in my browser like normal.
However, when I start the app using pm2, the app fails immediately and restarts consecutively.
I think it is because keystonejs has a known "error" that is not a real error, but just a warning when it starts.
From the "keystone-out-0.log" file -
Error ...node_modules/bson/build/Release/bson.node: invalid ELF header
However, in the "keystone-error-0.log" file, it gives me a different error that does not occur when I run it manually -
Error: ENOENT: no such file or directory, open '.env'
Any one faced anything similar?
Thanks
Okay, so I am using nodejitsu's forever(v0.11.1) module to keep my NodeJS(v0.10.28) + expressJS(3.5.1) server running on VPS(CentOS-6.4). Everything was working smoothly untill recently when I started getting following error while running command: forever start server.js As soon as I run this command I got the following error:
I tried to see the file: ls - l /root/.forever/tVYM.log, No such file was found
When I tried to start my node server using pm2, I got the following error:
I don't understand why is this happening even if I am root(su) user. Also, if I try to edit my server.js file, CentOS won't let me edit file and warns me about insufficient privilege.
But when I rebooted VPS and used forever, things were okay again but after some time, my server went down again and when I used forever to run my node app, forever threw the same error. I just can not see reason behind this. Thanks in advance
I installed the latest express-coffee and installed node-config too. I created a simple src/config/default.yaml
Database:
db_host: localhost
db_name: test
In my src/models/index.coffee
config = require('config').Database
console.log "host: #{config.db_host}"
But when trying to start the server with cake dev or even cake build && node app I am getting the following error:
Cannot write runtime.json file Error: ENOENT, no such file or directory
Tried searching for the issue here and on Google but wasn't able to find anything. Even the few hits on just ENOENT or node-config runtime.json haven't been helpful. Anyone else run into this problem before ?
It turns out the problem was where config/default.yaml was located. I had to move this to the root directory of the application. Moving it to the root - config/default.yaml fixed the issue.
The error message wasn't very helpful in figuring out what was going on.