How do I call a node application from a CloudFoundry buildpack? - node.js

I've created my own buildpack and now I need in the release to call to a node.js
application similar to the command in the manifest.yml where you are invoking the node application (command: node app). How I can do the same in the release/compile of the build pack?
In the compile I call to the node.js buildpack and afterwards, I want to run the node application (I Put it in the resources...)

One option would be to use the multi-buildpack to install the NodeJS buildpack first before your custom buildpack. You should be able to run NodeJS applications after that.

Related

Can someone tell me what is the build command for node js application?

I have created an API project with NodeJS and Express. Now I want to build the project and publish it to my IIS Server. Can someone guide me in the correct direction ?
You don't need to build a node.js app. You just need to run it with node.
eg node ./index.js
You don't need a web server to run a node.js app. Node is a server.
You can't build a node application, node is a server, you run it by running the index file, for production you simply run it and flag it as production.
This might help Hosting express node.js applications in IIS using iisnode. For more info on the project itself, you can find its repo here iisnode.

Why is Node.js required for Angular?

Why is Node.js required in order to use Angular?
In other posts, people say that it isn't required, and that it's only needed if you want server-side code. But the Angular documentation specifically states the need for Node.js in the "Getting Started" section. Why exactly is Node.js required? What if I want to use .NET Core as my server side back-end?
Straight from the Angular site:
Prerequisites before you begin, make sure your development environment
includes Node.js® and an npm package manager.
Node.js Angular requires Node.js version 8.x or 10.x.
To check your version, run node -v in a terminal/console window.
To get Node.js, go to nodejs.org.
Angular does not need Node.js directly and it is not mandatory to use Node.js. But you will need Node.js for all the build and development tools.
For an example these are few reasons that you need Node.js for building an Angular app,
npm (node package manager) comes with Node.js by default and it allows
you to manage your dependencies. So, you don’t have to worry for
operations like adding a dependency, removing some, updating your
package.json.
npm gives you angular cli or ng cli (angular command-line interface) which is a great tool for building your application easily
Node.js allows you to spin up a lightweight web server to host your application locally in your system.
You do need Node.js to develop Angular applications. All the tools you will run, while developing it, uses Node.js to run, like npm and the Angular CLI itself.
Node.js will serve your application on your machine. It has nothing to do with the server-side of your application, which can be any language you want.
Node.js allows you to spin up a lightweight web server to host your application locally in your system
NPM comes with node.js by default - used to manage dependencies
so you don't need to worry about adding/removing dependencies
(to node_modules folder, package.json/package.lock.json files)
NPM gives -> Angular CLI which is used to initialize,develop,scaffold & maintain angular application directly from command shell. It uses webpack for bundling your applications.
Also Angular uses TypeScript but browser understands Html & JavaScript only -> Typescript is transpiled into JS.
Angular CLI does all these behind the scene.

How to access Bluemix application's runtime shell as root?

I have a Nodejs application running in Bluemix. I try to run a command to install dependencies in Nodejs application container. I accessed it using application's runtime SSH. I need root privileges to install dependencies. It is asking me password for sudo command. How can i get that password?
You shouldn't be installing dependencies this way. The ssh terminal is intended for debugging purposes only:
If you need to troubleshoot an instance of an app, you can gain SSH
access to the app using the SSH proxy and daemon.
For example, one of your app instances may be unresponsive, or the log
output from the app may be inconsistent or incomplete. You can SSH
into the individual VM that runs the problem instance to troubleshoot.
Source: https://docs.cloudfoundry.org/devguide/deploy-apps/app-ssh-overview.html
NodeJS dependencies can be installed by adding a package.json file:
Cloud Foundry expects a package.json in your Node.js app. You can
specify the version of Node.js you want to use in the engine node of
your package.json file.
In general, Cloud Foundry supports the two most recent versions of
Node.js. See the GitHub Node.js buildpack page for current
information.
Source: https://docs.cloudfoundry.org/buildpacks/node/node-tips.html

Node app management complaining about missing start script

I have a node.js app that is pushing successfully into bluemix.
I'm trying to use the App Management feature.
But when I push I get the following warning.
WARNING: Avoid semver ranges starting with '>' in engines.node
WARNING: App Management cannot be installed because the start script cannot be found.
My start script is located in Procfile at my project root and contains which is starting my project ok.
web: gulp serve:prod
I tried putting a start command in package.json but still had this same warning. How can I get App Management installed?
App Management in the IBM Node.js buildpack currently only supports applications that are started using the node executable with a JS file. For example,
node [opts] server.js [args]
This is because many utilities in App Management are dependent on being able to manipulate the start command. For example, to start the application with inspector enabled, we need to be able to set the debug port (--debug $PORT).
Due to this limitation, App Management is not supported if your application uses gulp or similar build automation systems to start your application.

does a meteor.JS app compile to node.JS? If so, how

I remember hearing from someone that you can simply type in a command to compile a meteor.JS app into a node.JS app, and then deploy it as a node.JS app. Is that correct? Also, does that mean I can build a completely node.JS app by first building it in Meteor, and then using a command to compile it into node? If so, how can I do that?
You can use tool for doing that:
https://github.com/onmodulus/demeteorizer
Tutorial:
http://blog.modulus.io/demeteorizer
I believe you are looking for meteor bundle (See documentation). Meteor bundle constructs a tar.gz file from your meteor application. Once extracted, you should be able to run main.js in the extraction directory and your application built with meteor will run as a standard node application.
For clarification, here are some steps to bundle and run your node application built with meteor.
Within your meteor application directory, run:
meteor bundle appName.tar.gz
Then, unpack the bundle that meteor creates:
tar -xvzf appName.tar.gz
If the proper version of node is installed, you should be able to set your environment variables, and run the application.
export MONGO_URL='mongodb://localhost'
export ROOT_URL='http://myApp.com'
export PORT=5000
And finally, run your application. In the directory that you extracted the tar.gz file to, run:
node main.js

Resources