How can I publish a nodJS app on aws? - node.js

I'm using a free tier version of aws cloud, and have some trouble with loading up a nodeJs Application. I 've tried to follow the documentation of aws but it didn't work unfortunately. I choose the Elastic BeanStalk, from the services, and create a new Application. I choose nodeJs for the preconfigured platform of course. I make a zip with my app, and I really pay attention, to not have any parent folder above package.json, and app.js . As you can see on the picture above, I have a folder "public" which contains additional folders (css,img, javascript code). When I try to upload the project, I get an error message.
"Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js." In the project view I've got a health status "degraded", and an other error code: "i-045ac359227e3a9ae" Severe
I 've tried many php projects on this server, and everything worked fine,but I can't make it work with Node. Could you help me out please?
package.json:
{
"name": "kutyapplikacio",
"version": "1.0.0",
"description": "Egy alkalmazás kutyáknak és gazdáiknak",
"main": "server.js",
"scripts": {
"test": "test",
"start": "node server.js"
},
"author": "sethdevelop",
"license": "ISC",
"dependencies": {
"body-parser": "^1.17.2",
"express": "^4.15.3",
"express-mailer": "^0.3.1",
"express-mysql": "0.0.1",
"express-validator": "^3.2.0",
"mysql": "^2.13.0",
"nodemailer": "^4.0.1",
"nodemailer-smtp-transport": "^2.7.4"
}
}

The error message you wrote is : "Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js."
From the folder I only see you have app.js file.
And in your package.json, there are server.js:
"main": "server.js",
"scripts": {
"test": "test",
"start": "node server.js"
}
Perhaps you should change server.js to app.js ?
Update
Since you mentioned they have the same name:
could it be you zipped the folder instead of zipped the files ?
Same problem has been discussed here:
https://forums.aws.amazon.com/message.jspa?messageID=477087
https://forums.aws.amazon.com/thread.jspa?threadID=130140

Related

Parcel showing ENOENT: no such file or directory error when I save my html

beginner web dev here, first time using parcel and sass.
So, I have the parcel set up, but when I change and save the src/index.html, terminal shows me this error, instead of changing the dist/index.html.
It is very weird because in the error, there is supposed to be a file called dist/index.html.9424.5, which really does not exist in my case.
Here is my package.json set up:
{
"name": "calculator_project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "parcel src/index.html",
"build": "parcel build src/index.html"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#parcel/transformer-sass": "^2.7.0",
"parcel": "^2.7.0",
"sass": "^1.55.0"
}
}
Also, this is my folder structure and html
I will be very thankful for any tips or solutions.
Also, I am very sorry if I documented this error incorrectly, I am still pretty new to this.
Thanks for reading and help!

Node.js - Command npm run dev is stuck on message "Compilation complete. Watching for file changes"

When I launch npm run dev on my project, the process is stuck on the message below:
Compilation complete. Watching for file changes
and the server is not started.
I have the problem only on my Windows. When I launch the same command on my Ubuntu virtual machine, the server start as expected.
Do you know what how could I investigate more, have some logs or indications about the "error" ?
Thank you very much.
can you post your package.json file?
it is important, your script part is definded like that:
{
"name": "snail",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "nodemon app.js",
"dev":"node app.js"
},
"dependencies": {
"body-parser": "^1.19.0",
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
}
}
app.js is the filename of yout startfile.

How to deploy nodejs code from local machine to google app engine

I have just started with nodejs and app engine. I am following the tutorial
https://cloud.google.com/nodejs/tutorials
1) I have created a project then cloned the nodejs-mvms-quickstart repository.
2) Opened Development/source code and opened the nodejs-mvms-quickstart/1-hello-world
3) and started the node server
npm start
This is working fine. Now I want to deploy my nodejs application from my local server without copying to github and cloning on the server.
For this I am using following command
gcloud app deploy
but this is showing following errors:
If this is your first deployment, this may take a while...done.
Beginning deployment of service [default]...
Building and pushing image for service [default]
WARNING: No node version specified. Please add your node version, see https://docs.npmjs.com/files/package.json#engines
Some files were skipped. Pass `--verbosity=info` to see which ones.
You may also view the gcloud log file, found at
[C:\Users\Sunil Garg\AppData\Roaming\gcloud\logs\2017.05.07\20.38.59.221000.log]
.
Started cloud build [1cd2979e-527b-4d68-b430-31471534246e].
To see logs in the Cloud Console: https://console.cloud.google.com/gcr/builds/1c
d2979e-527b-4d68-b430-31471534246e?project=help-coin
ERROR: gcloud crashed (error): [Errno 10054] An existing connection was forcibly
closed by the remote host
If you would like to report this issue,please run the following command:
gcloud feedback
To check gcloud for common problems,please run the following command:
gcloud info --run-diagnostics
Here is my package.json
{
"name": "myapp",
"version": "1.0.0",
"description": "myapp",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"bugs": {
"url": ""
},
"homepage": "",
"dependencies": {
"body-parser": "^1.15.0",
"connect-timeout": "^1.8.0",
"express": "^4.13.4",
"generic-pool": "^2.4.2",
"multer": "^1.2.0",
"mysql": "^2.10.2",
"requestify": "^0.1.17"
}
}
What is the issue? Am I missing something?
Try adding the following 2 parameters to the package.json
Add the version of node your application is compatible with.
"engines": {
"node": "4.6.0"
}
since you're using npm start you might need this in the script parameter as well since npm start is calling command stated in start in script param, change app.js according your application, like node quickstart.js. Always make sure to specify the path if your package.json is in the root directory and the .js is in a sub directory as well.
"scripts": {
"start": "node app.js"
}

Generating a bin folder in NodeJS with Fedora

I'm learning to do CRUD in Node, and am having trouble generating the bin folder. Also, the package.json folder which I've generated doesn't contain the dependencies needed to run on localhost.
To generate the app, I used express MyApp
and then npm install npm install mongoose --save
This gave me:
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "3.5.2",
"jade": "*",
"mongoose": "^4.5.4"
}
}
It did not generate a bin folder, or www file hiding elsewhere. I'm using Fedora 23, in case that makes a difference here. Please let me know if there's something I've missed, or if you have any suggested work-arounds.

Custom start-up command for Azure Node.js Web app (ES2015/babel)?

I am migrating an ES2015 node.js application from Heroku to Azure.
The current start-up command running on Heroku is
"start": "./node_modules/babel-cli/bin/babel-node.js index.js"
However, on Azure I am getting
Invalid start-up command "./node_modules/babel-cli/bin/babel-node.js index.js" in package.json. Please use the format "node <script relative path>".
Which indicates that Azure only supports vanilla node for npm start.
I'm aware that running babel-node on production isn't ideal, but I was hoping for a straightforward migration.
Three options that would require a bit of re-architecting are:
Using a gulp workflow to precompile ES2015: https://github.com/christopheranderson/azure-node-es2015-example
Using a bash workflow to precompile ES2015: http://www.wintellect.com/devcenter/dbaskin/deploying-an-es6-jspm-nodejs-application-to-azure
Using babel-register ala [link in comments].
I suspect option 3 will be easiest but checking if anyone has come across a similar issue and managed to run babel-node directly in npm start on Azure.
According your issue, please modify your start npm script to node ./node_modules/babel-cli/bin/babel-node.js index.js on Azure Web Apps.
Here is the content in test package.json:
{
"name": "website",
"description": "A basic website",
"version": "1.0.0",
"engines": {
"node": "5.9.1",
"npm": "3.7.3"
},
"scripts": {
"start": "node ./node_modules/babel-cli/bin/babel-node.js index.js"
},
"dependencies": {
"babel-preset-es2015": "^6.6.0",
"babel-cli": "^6.0.0"
}
}
Meanwhile if you need a higher Node.js version, you can specify in package.json, refer to https://azure.microsoft.com/en-us/documentation/articles/nodejs-specify-node-version-azure-apps/ for more.
Just as what Gary said, you need to update your package.json using the command below.
"scripts": {
"start": "node ./node_modules/babel-cli/bin/babel-node.js index.js"
}

Resources