Install mocha on VirtualBox with Ubuntu image - node.js

I'm using Oracle VirtualBox in Windows 7 with an image of Ubuntu 13.04 x86.
I've already downloaded a github project, I've run:
sudo npm install -g mocha
sudo npm install mocha
npm install
nodejs is installed (nodejs --version retrieves v0.10.25)
If I run:
which mocha
I get: /usr/bin/mocha
Then, I run:
mocha test/test1.js
I just get the command prompt, nothing happens, I don't see the tests running.
I went to the mocha folder inside node_modules/mocha and I see two files: mocha and _mocha, I run both and nothing happens
When I say "I just get the command prompt", this is what I can see:
ubuntu#ubuntu-VirtualBox:~/guillermo/myproject$ mocha --reporters
ubuntu#ubuntu-VirtualBox:~/guillermo/myproject$
Any advise?
Thanks!!! Guillermo.

You probably installed the wrong Ubuntu package for node.js. If you did sudo apt-get install node, then the package "ax25-node" is installed instead of node.js.
See this page on how to install node.js on Ubuntu using nvm.
If you want to use ubuntu's package repository for node.js, then do sudo apt-get install nodejs, and the resulting binary is called nodejs instead of node.

Related

How to install node/npm so that 'sudo npm' works on an ec2 instance?

Answer: Follow the steps in this link
http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/
I am running ubuntu on an ec2 instance and need to sudo npm install something. I am given the error that sudo npm is not recognized.
There is a previous thread that is 7 years old. On EC2: sudo node command not found, but node without sudo is ok I tried every solution there and nothing worked.
I think the problem is using NVM to install npm and node. How can I install these so that they are compatible with sudo? Thanks!
You can run the following command
sudo yum install nodejs npm --enablerepo=epel
For more, you can also install using the following link also: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html
Second Approach:
Install NPM
git clone https://github.com/isaacs/npm.git
cd npm
sudo env PATH=$HOME/local/node/bin:$PATH make install
Now you can install npm packages and run javascript node files as usual!
sudo npm install forever -g
sudo npm install express -g
Resource Link: http://www.wisdomofjim.com/blog/how-to-install-node-and-npm-on-an-ec2-server
You can use NVM. You can follow this link which gives proper steps to install node on ec2 instance.
I dont know if my problem is the same as yours (i think is similar), but i tried to run "sudo npm install" on a amazon linux ec2 machine and it gave me the "sudo: npm: command not found" type of problem.
I followed the instructions recommended by AWS to install node and NPM (https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html).
I solve this by changing the owner and group of the directory and files (package.json and package-lock.json):
chown ec2-user:ec2-user nameDir
and then i run npm install again. It worked!

Nodejs or node returns nothing on Ubuntu

I've built a Javascript app running on Node within my MacOS environment, and everything works great. Now I've created an Azure Ubuntu server, rsync'd the source from my machine.
I've duplicated the app requirements by installing npm, node, and all the packages required. I SSH into the server and when I run the app from the Ubuntu server via
$node app.js
All that is returned is
$
Reading that Ubuntu uses nodejs-legacy, i've also tried
$nodejs app.js
Same result
$node -v
v4.7.2
I've also built a package.json file and when executing with
npm start
it immediately returns back to $.
The reason why it wasn't working is the default APT repository that is called when installing nodejs on Ubuntu is outdated. I ran the following to code to fix the problem. It automatically uninstalls all the other incorrect packages, sets the correct repository, and re-installs.
# Sets up the correct APT repository hosted by NodeSource, and adds the PGP key to the system's APT keychain
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
# Installs Node.js
$ sudo apt-get install -y nodejs
# Updates NPM
$ sudo npm install npm --global
All apps work as intended now!

$ babel and $ babel-node don't launch the REPL

I'm trying to setup babel on Ubuntu 14.04 but it doesn't seem to be working!
Here are some outputs that may be required:
$ which node
/usr/sbin/node
$ which nodejs
/usr/bin/nodejs
$ which babel
/usr/local/bin/babel
$ which babel-node
/usr/local/bin/babel-node
When I execute babel or babel-node the prompt just returns. The same happens on executing the commands with a filename as argument. (The file has just console.log("hello").
How do I fix this?
The /usr/sbin/node vs /usr/bin/nodejs issue has been covered in Cannot install packages using node package manager in Ubuntu but basically Ubuntu has a separate node package that is NOT Node.js. The package for Node.js on Ubuntu is called nodejs. If you have both installed, it means your scripts will try to run using the other unrelated application. One option is to symlink nodejs to node.
The best solution however would be to use something like nvm to install node for your user without installing it globally. Then you can install and update node versions extremely easily, and your PATH will always reference node properly.
Changing node to nodejs in the first line of /usr/local/bin/babel-node and /usr/local/bin/babel solves it.

Express command not working in terminal

I am kind of new to node.js. I installed node fine and it works. I can run the node command in the terminal as well as the node package manager command(npm). Working on a Mac by the way. So I installed express globally with the following command:
sudo npm install -g express
After I was done installing it globally I installed it in a small folder where I am working on a project.
sudo install express
That gave me a node_modules folder inside of my site folder. After I was done that I went to install stylus using the express command and I got the error that express is not a command.
express -c stylus
Can anyone shed some light on this issue? I also tried to link the global express to the folder where I am working on the project using the following command:
sudo npm link express
The terminal said that this command ran, but I still cannot run the express command.
Thanks for asking questions on this one. I found that running express-generator instead of just express fixed the problem. The following code in the terminal worked.
sudo npm install -g express-generator
Thanks again,
If your express binary keeps doing nothing. Install node-legacy:
sudo apt-get install nodejs-legacy
on ubuntu 14.04 nodejs 0.10 express did not work on terminal, though
sudo apt-get install nodejs-legacy
made it to work.
I faced similar issue. I tried all the solutions mentioned here. However couldn't get my problem solved.
This happens when location of express and nodejs is not same.
Issue arises when Node is installed using homebrew.
Just use this command export PATH=/usr/local/share/npm/bin:$PATH
NOTE: replace path with the path of express.
Follow this link for help.
Make sure you have package.json & index.js files. And instaled express-generator with -g tag.
If still getting error use like ex:npx express --view=pug myapp --git
I fixed this on my mac by forcing my user to own /usr/local/lib and running the command to install express-generator globally:
sudo chown -R $USER /usr/local/lib
then:
npm install -g express-generator
After this you can go ahead and run your express commands:
express -h

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