Install node.js on AWS OpsWorks php app server - javascript

I have set up a PHP App Server Layer in my AWS OpsWorks stack which works fine. Now I need to have it install node.js as well in order to compile and minify stylus and coffeescript, run browserify and also compress pngs, all through Grunt on each deploy.
The steps/requirements are:
Install node.js
Install grunt-cli globally
Run npm install
Set write permissions for node on public/assets/
Run grunt deploy "install" hook preconfigured in package.json
Ideally uninstall node, npm and all node modules as they are no longer needed
I have tried setting the official cookbook as custom chef repo and including all the recipes from the node.js app server default recipes, but they fail as the app is not a node.js app.
Does anyone have any experience with this?

Related

npm run build cannot access in localhost

I want to test my react/ node.js web app with a production build. I already run npm run build at the app directory and created build folder.
I was unable to run the application using localhost:8080 (server port).
Are there any ways to double check if the application is actually running in that port or access production-ready application?
PS. I used serve to host the application but it posts error 404: The requested path could not be found
Thank you for your help.
Every SPA application has its own package.json file. Inside you have to see the script section:
Normally after you run nm run build you have a compiled version of your code.
At this point, you have a see the dist folder.
After this, you can either run npm run start and you have to see
(this option is not suitable for SSR frameworks like NUXT or NEXT)
or if you don't have that option install an npm package that renders your compiled code by doing the following:
npm install -g serve
serve -s build
and you have to see

How to develop client side library and npm library ?

I would like to develop a JS test library for client & node.
I need to develop for two different repo's?
Lets take for example QUnit:
for client side I will use:
https://code.jquery.com/qunit/qunit-2.3.0.js
But for node develop, I will use :
npm install qunitjs
Those are 2 different code repo's, aren't?
For the example, lets puts aside the testrunner, etc..
Thanks!
Originally the "npm" used to stand for the "Node Package Manager".
Currently, the npm Registry is a public collection of packages of open-source code for Node.js, front-end web apps, mobile apps, robots, routers, and countless other needs of the JavaScript community.
And npm is the command line client that allows developers to install and publish those packages.
See: https://www.npmjs.com/about
So you can use npm to package front-end code just like you can use npm to package Node code. Sometimes it makes sense to publish two packages - one for frontend and one for backend - but sometimes you can have just one.
For packaging frontend code there are more options like Bower: https://bower.io/
For packaging Node code the most popular choice is npm but you can install code directly from GitHub or other git repos.
As an example you can see my module tco that is on npm:
https://www.npmjs.com/package/tco
But also on GitHub:
https://github.com/rsp/node-tco
So you could install it with npm either from the npm Registry or from GitHub:
npm install tco # <-- from npm registry
npm install rsp/node-tco # <-- from github
Additionaly you can use it on the frontend from the CDN available for all code on GitHub:
<script src="https://cdn.rawgit.com/rsp/node-tco/v0.0.12/tco.min.js"></script>
If you want your code available on that CDN as well, see RawGit:
https://rawgit.com/

How to run AngularJS app created using yeoman

I'm new to AngularJS. I created a sample app using yeoman for AngularJS. The source is hosted on github here https://github.com/Omnipresent/demoangularapp
I'm not sure how to run the app?
How can I run the app so that it runs on my localhost server and I can play around with it?
Depending on which task runner you are using: Run CLI command gulp serve, grunt serve or npm run serve if you have the node package serve installed to start a local webserver. In your case it should be gulp serve while you using gulp this time. Run this CLI commands in your project root directoy or create a host/vhost witch points to your yo generated app directory where your index.htmlhas been created.
This commands will start an local webserver.
For mor information checkout the yo documentation.
It doesn't matter if application is generated with yeoman, it's just a scaffolding tool. You should run bash with commands: npm install, gulp serve. also make sure that you have gulp installed both globally and locally.

Can meteor run without dependencies on external services?

I am trying to build an application for a local private network (with no access to the web) using meteor. From my research, I can't seem to find a way to take meteor 100% 'offline' meaning, no dependencies to web services to build / run.
I've looked at the following links - How can Meteor apps work offline? and here - https://groups.google.com/forum/#!topic/meteor-talk/tGto0cCsvXA
yet neither threads give a clear cut answer on if it's possible and how to go about formulating an approach.
I am hoping someone could provide guidance on how I would go about removing the meteor framework dependencies for online services. If this won't be possible, other suggestions for frameworks that play well for local private network apps would be most appreciated.
If I get you right, you wish to build a webapp that is to be deployed on a local network.
If that is indeed the case, then the answer is yes.
An example setup would be:
a server computer with linux (ex: Ubuntu server)
node installed on it (0.10.29 is necesarry for a 0.8.3 meteor app - see: https://askubuntu.com/questions/49390/how-do-i-install-the-latest-version-of-node-js)
mongodb installed and running as a service
then on your dev machine run
meteor bundle --directory /your/independent/app
Copy the app folder to the target machine
Though you will find more information in the bundled README (see below) I use the following bash script to start my app
rm -rf programs/server/node_modules/fibers
npm install ~/.meteor/tools/latest/lib/node_modules/fibers/
# npm install fibers#1.0.1
export MONGO_URL='mongodb://localhost/survey'
export PORT=3000
export ROOT_URL='http://127.0.0.1'
~/bin/node main.js
And that's about it. With these steps you can deploy an app created by meteor on any machine. The only dependencies being node (specific versions) and mongodb.
README (generated by meteor bundle)
This is a Meteor application bundle. It has only one dependency:
Node.js 0.10.29 or newer, plus the 'fibers' and 'bcrypt' modules.
To run the application:
$ rm -r programs/server/node_modules/fibers
$ rm -r programs/server/node_modules/bcrypt
$ npm install fibers#1.0.1
$ npm install bcrypt#0.7.7
$ export MONGO_URL='mongodb://user:password#host:port/databasename'
$ export ROOT_URL='http://example.com'
$ export MAIL_URL='smtp://user:password#mailhost:port/'
$ node main.js
Use the PORT environment variable to set the port where the
application will listen. The default is 80, but that will require
root on most systems.
Find out more about Meteor at meteor.com.

Using socket.io and express modules without npm

I am working on a project for an embedded Linux system (busybox made with buildroot). I am wondering if it is possible to use node.js modules socket.io and express without having to install or run npm. The goal is to be able to have buildroot configured to create a busybox image that simply includes node.js, and then place all my javascript files in the proper directory and execute node app.js from the command line to run the node application (which will use socket.io and express).
So, for example on my development machine (That does have node.js and npm installed), I could run npm install socket.io so it would get socket.io and all its dependencies and install it in the node_modules directory of my project. If I place all those files in a directory and move them to the production environment (embedded Linux with just node.js installed and where npm install socket.io was never run) would my application work?
If I place all those files in a directory and move them to the production environment would my application work?
Yes, it would. However, if you do have any binary dependencies, they need to be recompiled, so it's a bit trickier. If you don't, you'll be fine.

Categories