I'm still new to node.js and mongodb. Now I'm trying to solve this problem.
I have instructions to run my server without any problems, I follow them and yes my server works. But when I switched the server off then run it again I face this bug:
[vagrant#localhost ~]$ node /opt/inapsrv/app/app.js
app-api listening at http://0.0.0.0:7000
/opt/inapsrv/node_modules/fileupload/lib/modules/file.js:23
throw error
^
Error: ENOENT, mkdir 'data/imagex/'
And here is the line of the directory above taken from app.js file:
var imagePath = 'data/imagex/';
I tried to:
make vagrant and mongo users as super users and they have the root permissions.
to run "sudo node /opt/inapsrv/app/app.js"
run "forever /opt/inapsrv/app/app.js"
and it didn't work.
I don't know why it successfully ran the first time, and then it didn't!
Any help?
I suspect you're using node module fileupload for the upload job. The source code fragment in fileupload that throws your error can be found here.
The problem with the code used in fileupload module is that it does not create recursive directories since fs.mkdir is used. To fix your issue try to create the upload directory or at least data upfront. You could do this by a npm script, in app.js using the mkdirp or simply by a shell script.
The problem described is not related to mongodb or mongoose.
Related
I'm trying a simple sample of node express that I copied from online. The script is below which I think is pretty standard.
var http = require('http');
http.createServer(function(request, response)){
response.writeHead(200);
response.write("hello");
response.end();
}).listen(8080);
console.log('listening on port 8080...');
I used the bash on ubuntu on windows command as follows:
npm init
node SampleServer.js (the name of my file)
When I do this, I expect some response from the command line. But when I enter the "node SamplerServer.js" command, nothing happens. When I direct the browser to port 8080, I get an error message as well.
I'm using nodeclipse and the installing that on my machine was pretty complicated. Prior to any of the steps above, I created an express project in eclipse ide. It seems to perform a lot of pre steps but in the end, I think I'm getting some of the error messages below. I'm mentioning this because I'm thinking perhaps I installed one of the modules wrong.
enter image description here
Start with simple stuff...
Use express-generator to create simple app by the following command
1-> npm install -g express-generator with root or Admin access
2-> Run express demoapp.
3-> Navigate to demoapp
4-> Do npm install
5-> Run from command with npm start: it run by default on http://localhost:3000
Hit that URL from Browser
Im following the tutorial here. I when trying to run the project at this point. I get an error saying that there is no defined templating engine. The tutorial has us remove the app.use
Below is my console error when trying to go through the tutorial. Just to be sure I went back through it three times. I get the same error. I notice in the History.md that this was addressed but I cant figure out what if anything i am supposed to do with that info. Can you advise?
This is the tutorial: https://azure.microsoft.com/en-us/documentation/articles/documentdb-nodejs-application/
I get the error on trying to run npm start to see the todo UI. When I run start at the beginning of the tutorial, it works.
Thank you.
Kaona (master *) todo $ npm start
> todo#0.0.0 start /Users/Kaona/GitHub/todo
> node ./bin/www
/Users/Kaona/GitHub/todo/node_modules/express/lib/view.js:62
throw new Error('No default engine was specified and no extension was provided.');
^
Error: No default engine was specified and no extension was provided.
at new View (/Users/Kaona/GitHub/todo/node_modules/express/lib/view.js:62:11)
at EventEmitter.render (/Users/Kaona/GitHub/todo/node_modules/express/lib/application.js:569:12)
at ServerResponse.render (/Users/Kaona/GitHub/todo/node_modules/express/lib/response.js:961:7)
at /Users/Kaona/GitHub/todo/routes/tasklist.js:27:17
at /Users/Kaona/GitHub/todo/models/taskDao.js:43:17
at Base.defineClass._toArrayImplementation (/Users/Kaona/GitHub/todo/node_modules/documentdb/lib/queryIterator.js:187:17)
at /Users/Kaona/GitHub/todo/node_modules/documentdb/lib/queryIterator.js:183:26
at /Users/Kaona/GitHub/todo/node_modules/documentdb/lib/queryIterator.js:234:17
at successCallback (/Users/Kaona/GitHub/todo/node_modules/documentdb/lib/documentclient.js:2069:17)
at IncomingMessage.<anonymous> (/Users/Kaona/GitHub/todo/node_modules/documentdb/lib/request.js:84:13)
Per #ryancrawcour #larrymaccherone's direction. The solution is to add app.set('view engine', 'jade'); to the app.js file in the tutorial. See Error: No default engine was specified and no extension was provided
According to the error, I guess your machine is a Mac, but I think my steps below on linux that's similar with yours on MacOS.
The tutorial sample shows a local node app created by express generator for using Azure DocumentDB.
So the first step is creating an Azure DocumentDB instance on Azure new portal. I think it's simple, and copy the connection information of the DocumentDB created for the express app.
To create a express app like the tutorial doing, I did the steps below.
Command npm install express-generator -g
On MacOS, may need to add the prefix cmd sudo because it's for global env, see http://expressjs.com/en/starter/generator.html).
Command express todo
Generate a empty express app via express generator
Command cd todo && npm install
installation for dependent libraries registed in the package.json
Now, you can command npm start in the dir todo and browse the url http://localhost:3000
Command git clone https://github.com/Azure-Samples/documentdb-node-todo-app.git from Github project https://github.com/Azure-Samples/documentdb-node-todo-app and copy the files of the path src of git repo to the dir todo.
Edit & configure the config.js with the connection information of your DocumentDB.
Hope it helps. Best Regards.
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 am trying to run my meteor application on my local network so that when I am off-line I can still use the application on any devices connected to my network. I have been following http://ox86.tumblr.com/post/45184656062/running-your-meteor-js-application-on-your-own-server as a basic tutorial on how to do this. I am new to mongodb and node.js, which causes some trouble. However it seems that everything is working except I do not know where my app is running or what the address is? For example after I complete step 4 from the tutorial
export PORT=8080
export MONGO_URL=mongodb://bill:123456#localhost:27017/dbName
after navigating inside my bundle where main.js is I use
forever start main.js
There are no errors, but I don't know where my app is or if it is even working. Once again I am new to this idea of hosting my own meteor app. Any ideas or suggestions of what I am doing wrong. Also an explanation of the process would be much appreciated. Thanks for the help!
It's likely you have errors. You should check with forever logs main.js to see what you get.
From what it looks like you may have missed the ROOT_URL variable too.
export ROOT_URL=http://www.yoururl.com
export PORT=8080
export MONGO_URL=mongodb://bill:123456#localhost:27017/dbName
forever start main.js
The best check would be to see what you get in the forever logs. Also you may have to install fibers (before you start your app) if you have some error in your logs like invalid ELF header
cd bundle/programs/server/node_modules
rm -r fibers
npm install fibers#1.0.1
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.