Setting up StrongLoop with my node applications - node.js

I'm currently testing platforms that provide a monitoring service for nodejs application. So I found (for now) StrongLoop and AppDynamics (recently acquire nodetime).
Actually I'm testing StrongLoop service. I have followed all the steps describe in the documentation but I can't see any data on the dashboard, only the StrongLoop Demo App. Here is all the steps :
npm install -g strongloop
npm install --save strong-agent
$ slc strongops (command that create strongloop.json file)
add "require('strong-agent').profile();" line on first line of each applications (2)
restart my applications (using PM2 to manage my applications - cluster mode, AWS EC2, Ubuntu)
Any idea ?
Tank you.

My answer with links got deleted by another SO user so I'm listing the steps here.
First uninstall using this
$ npm uninstall -g strong-cli
$ npm uninstall -g loopback-sdk-angular-cli
and then install
npm install -g strongloop
You can now run slc strongops
and let us know how it goes.

I created a Linux init.d Daemon script which you can use to run your app with slc as service:
https://gist.github.com/gurdotan/23311a236fc65dc212da
Might be useful to some of you.

Related

How can Nodejs apps always run as a Windows service?

I have windows Server 2016 cloud hosting. I broadcast my sites on IIS.
I have 2 apps running on Nodejs. I log out of windows after configuring my applications.
My IIS sites continue to run, but my nodejs applications quit when I log out or restart windows.
I have followed the steps below to fix this issue.
I installed the pm2 library. Globally.
npm install --global pm2#latest
I installed the pm2-windows-service library. Globally.
npm i pm2-windows-service -g
I installed the pm2-windows-startup library. Globally.
npm install pm2-windows-startup -g
I uninstall running services to avoid running apps repeatedly.
pm2 kill
If there are any running services, I first uninstall it.
pm2-service-uninstall
I installed the pm2-service-install library. I named it "pm2Service1". I see it started when I enter services.msc.
pm2-service-install -n pm2Service1
I start the startup service for applications to start when Windows opens.
pm2-startup install
I go to the directory where the application is installed and run the application with pm2. (If I don't enter the directory and run it, it gives an error. Can't read the sql / file.sql file.)
c:
cd C:\webSites\myService1
pm2 start app.js
I check the application with list and show, and see if it works.
pm2 list
pm2 show 0
After making sure it works.
I'm recording running applications.
pm2 save --force
When I do these procedures and log off windows, I can access the application from outside.
But when I restart windows the application does not work. I have to repeat the same steps every time it starts up.
When Windows restarts, "pm2Service1" seems to be working. But pm2 list the lists as empty.
I accomplished this on my servers by using NSSM Service. Once you install it, go to NSSM folder and type
nssm install PM2
You can find the entire tutorial here:
https://lakin-mohapatra.medium.com/register-pm2-as-a-service-in-the-windows-server-747f19e2ff2a
Best practice AFAIK is using nssm + "windows batch file" to start your app.js, for more details you can check this link.

loopback "lb4" command is not working after successfully installation of loopback CLI using "npm i -g #loopback/cli"

I have successfully installed loopback CLI using npm i -g #loopback/cli after that I'm trying to create app using lb4 app command terminal and it shows me Command 'lb4' not found.
Only lb app works for version 3 and 2 but I want to create application compatible with loopback version 4.
I had the same problem and solved it by updating to the latest version of Node.js (10.7 as of now). Then I reinstalled the LoopBack CLI with npm i -g #loopback/cli and the lb4 app command worked just fine. Also, I was executing all the commands as admin, in case it helps.
If you're having trouble creating a global link on Windows 10 (like I did).
Consider installing in the NodeJS project folder as a work-around.
Simply execute:
npm install #looback/cli --no-save
Notes:
This will install the cli without listing it as a dependency in your package.json.
This will allow you to run lb4 app only in the root folder of project where you ran the command.
This solution is not ideal since you'll have to do this for each project. However I figured it beats having to install a new version of NodeJS just for the installer to clear some cache/configuration that got messed up over a long time-period.
Upgrade your Node.JS to version 8.9 or higher.
It's a Prerequisites.
See the doc: https://loopback.io/doc/en/lb4/Getting-started.html#prerequisites
Also some time npm installs the JS module successfully but does not add in environment variable. Find the npm folder path (in my case C:\Users\user_name\AppData\Roaming\npm) and add into class path. After adding environment variable restart the command prompt.
I was also facing same problem. But then I ran the command using sudo and it worked. sudo npm i -g #loopback/cli.
sudo update-alternatives --install /usr/bin/lb4 lb4 /opt/nodejs/node-v19.1.0/bin/lb4 0
This command will be more useful to solve this problem.
You can replace nodejs path according to your system.(/opt/nodejs/node-v19.1.0/bin)

Installing Angular CLI with npm install fails

I am new to AngularJS, just started an online course.
I am trying to install angular CLI on my computer at work running Windows 7.
I opened command line as administrator and running npm install -g #angular/cli. Installation starts and after a few minutes I get an error:
I see the notification "operation not permitted", but I am the administrator of the computer and the command line I run as administrator.
What am I doing wrong?
The same installation I did on my laptop at home and it was successful.
I am checking with our IT support about other possible causes and will appreciate any help.
This is not a duplicate of Fail to install npm package “npm ERR! errno -4048” or npm install -g angular-cli fails.
Ignoring the error and running gn -v I get the following:
Is this correct? Was Angular CLI installed?
These issues are because of the company proxy settings.
Check with your admin to get the proxy for http or https.
It will be something like this:
http_proxy = http://http.myproxy.com:8000
https_proxy = http://http.myproxy.com:8000
Replace myproxy with the name of company proxy.
Then go to the command prompt and run the following command to set the proxy. Later you can run any command like npm install -g #angular/cli to run. It will work
npm config set proxy http://http.myproxy.com:8000
npm config set https-proxy http://http.myproxy.com:8000
That fsevents library has peculiarities on Windows. So I suggest you ignore the error message and run ng -v from the command prompt to confirm you got the Angular CLI libraries installed.
You need to run the npm commands on node.js command prompt but not on windows command line.
Workaround: install git bash on windows.
As the error message suggest, you don't have some permissions to execute your command.
Depending on your system, you should run the command as an administrator.
Also, don't mix AngularJS (the first Angular framework) and Angular (also known as Angular 2, 4 and 5 now) . They are radically different in their syntax and uses.
Run below command and try installing angular cli again.
npm cache clean -f
This worked for me manytimes.

serverless: command not found in ubuntu 16.04

I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: npm install -g serverless in the terminal.
But when I try to run serverless it returns an error saying serverless: command not found. Below is a screenshot for reference:
Try running,
npm config set prefix /usr/local
and then,
npm i -g serverless
If the above options are not working (due to insufficient access or sudo access), following one will definitely work as it's saving the serverless into your local.
npm install serverless --save-dev
node ./node_modules/serverless/bin/serverless deploy
Reference link - https://serverless.com/framework/docs/providers/aws/guide/services/
Was getting the same error serverless: command not found but instead of NPM was using YARN. To fix it had to execute (or better add to your ~/.bash_profile):
export PATH="$PATH:$(yarn global bin)"
then, if not already installed:
yarn global add serverless
my recomendation here is to allways install the serverless framework as a dev dependency (npm install serverless --save-dev) specially if you're working in a team where each member can have its own version of the framework. After that, you can call the framework using npm scripts. For example, you can create a new entry in the scripts section like this: "deploy" : "serverless deploy" and call it using npm run deploy.
Try with the following order
npm config set prefix /usr/local
sudo npm i -g serverless
sudo /usr/bin/node /usr/local/lib/node_modules/serverless/node_modules/tabtab/src/cli.js install --name serverless --auto
Another option, following this post, is to try npx serverless ...

AngularJS testing using Karma

I am very new to AngularJS and trying to test a piece of functionality using Karma.
I installed node.js and when I open it and enter the following it doesn't do anything.
$ npm install -g karma
Please anyone can help me how can I achieve this.
I ran into a similar issue. I believe I wrote a fairly complete blob post about how to Setup AngularJS, Angular Seed, Node.js and Karma. This post describes how to install Karma on a windows computer using the command prompt.
http://bardevblog.wordpress.com/2013/07/28/setting-up-angularjs-angular-seed-node-js-and-karma/
On Windows, you can install Karma from the Command Prompt. Do not install it from within Node.js.
Steps to install Karma
1.install nodejs from https://nodejs.org/download/ site appropriate for your system
2.open command prompt and traverse to your project path 'C:\project folder\'
3.type and run this in command prompt ->npm install karma --save-dev
4.type and run this in command prompt ->npm install -g karma-cli

Resources