I have just read tutorial on Angularjs and wanted to run test application (by (C) Wahlin Consulting) from http://tinyurl.com/AngularJSDemos . Its readme informs that:
NODE.JS OPTION:
If you want to run the site using Node.js (install it from http://nodejs.org) run the following at the command-prompt from within the AngularJSDemos folder:
node server.js
Now navigate to http://localhost:8080/DemoList.html or http://localhost:8080/CustomerManagementApp in your browser.
I have installed nodejs and tried to launch it from terminal in my Ubuntu system:
mainuser#mylaptop:~$ cd /home/mainuser/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos/
mainuser#mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node server.js
The program 'node' can be found in the following packages:
* node
* nodejs-legacy
Try: sudo apt-get install <selected package>
mainuser#mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ sudo apt-get install node
...
mainuser#mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node server.js
mainuser#mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node server.js
mainuser#mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node
mainuser#mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node ./server.js &
[1] 11153
mainuser#mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node ./server.js
[1]+ Exit 1 node ./server.js
mainuser#mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ node ./server.js
mainuser#mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$ sudo apt-get install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version.
The following packages were automatically installed and are no longer required:
kde-l10n-engb kde-l10n-pl linux-headers-3.13.0-32
linux-headers-3.13.0-32-generic
Use 'apt-get autoremove' to remove them.
0 to upgrade, 0 to newly install, 0 to remove and 28 not to upgrade.
mainuser#mylaptop:~/Ebooks/AngularJS/AngularJSDemos/AngularJSDemos$
But whatever I do, I cannot launch this example. In Chrome "This web page is not available" and in Firefox "Unable to connect". Moreover, it looks like I simply cannot launch it in terminal.
How to launch this example?
I'd recommend using nvm to install node and manage different version on your system.
It's quite easy:
# First, we need to clone the nvm repository:
$ git clone https://github.com/creationix/nvm.git ~/.nvm
# Then, we need to add the following line to our .profile, .bashrc or .zshrc:
$ echo "source ~/.nvm/nvm.sh" >> .zshrc
Installing nvm is not enough, we now need to install node & npm.
# To print out the list of all the available versions, simply run:
$ nvm ls-remote
# We want to install the current stable version which is v0.10.26, so we need to run:
The -s flag means we want to compile node from source.
$ nvm install -s v0.10.30
When the installation process is finished, our brand new node and npm will be installed!
The great thing with nvm is that you can use a different version of node in each of your shell instances. But if you want to stick to the latest version, you can set it as default by running:
$ nvm alias default 0.10.30
Make sure everything is up and running by typing node -v && npm -v
Here's a different approach for this problem, the tutorial is suggesting using npm and it's fine. but it takes time, an internet connection and setting up.
Here's an alternative way, if you're already using Ubuntu, python should already be installed in your system. your python installation already comes with a simple HTTP server you can use to run your angular application.
in your console, type python -m SimpleHTTPServer 8080
then direct your browser to localhost:8080
and locate your angular project. then it should run properly.
You probably installed incorrect node package.
Thanks to that your node command is not equal to nodejs but invokes something totally different.
Try with
nodejs ./server.js
Install node in ubuntu using
sudo-apt-get install nodejs
sudo apt-get install npm
sudo apt-get install build-essential
and then run your server with following command
npm start
Related
I am trying to install mongoDB as a macOS service but I am running to some errors
I first put in the terminal
brew tap mongodb
Nothing really happens.
But, when I run:
brew install mongodb-community#5.0
I receive:
Warning: No available formula with the name "mongosh" (dependency of mongodb/brew/mongodb-community). Did you mean mongocli?
==> Searching for similarly named fo This similarly named formula was found: mongocli ✔
To install it, run: brew install mongocli ✔ It was migrated from mongodb/brew to homebrew/core.
Finally, when I run
brew services start mongodb-community#5.0
I receive
Error: Formula 'mongodb-community' is not installed.
Any advice?
I had the same happen, however my issue was actually with this error:
fatal: could not solve HEAD to a revision
solve it using:
git -C $(brew --repository homebrew/core) checkout master
you can also:
brew update
brew upgrade
brew upgrade --cask
brew cleanup
and then restart the mongodb community edition install process again! Worked for me!
I am experiencing the exact same problem (I am using MacOC version 11.5.1).
The reason why your brew tap mongodb does not seem to be doing anything may be because you have already tapped into mongodb. Try untapping with brew untap mongodband retapping with brew tap mongodb/brew.
After you have established the connection, try installing again with brew install mongodb-community#5.0. At this stage, I could not get the installation to work for version 5.0 so I installed version 4.4 instead (with brew install mongodb-community#4.4).
After that, try running mongo with brew services start mongodb-community#5.0 (or brew services start mongodb-community#4.4 if you have installed 4.4 version) and it should work just fine!
If you have installed version 4.4, be sure to run the command PATH="/usr/local/opt/mongodb-community#4.4/bin" mongo to start the mongo shell.
I was also having the same issue. This solved it for me:
git -C $(brew --repository homebrew/core) checkout master
brew update
brew upgrade
brew upgrade --cask
brew cleanup
Then install the latest version of Mongodb community using:
brew install mongodb-community#6.0
Note: version might be outdated at the time you're reading this
Check with brew list | grep mongo that mongodb-community, mongodb-database-tools, mongosh exist at your PC. If they do not exist, install them with brew.
Recently also installed mongodb V4.4.5 and can not start it with brew services start mongodb-community. For me works starting it manually as a background process as admin sudo mongod --config /usr/local/etc/mongod.conf --fork
And last call mongo to work with mongoDB shell.
Reason: directory/file access issue. Not sure.
I am using gulp-angular-protractor for end-to-end testing of my web app. I am getting the following error recently but earlier it used to work perfectly.
Any help to fix this issue will be appreciated.
Details:
OS - Ubuntu 16.04,
node - v6.12.2,
npm - v3.10.10,
Vagrant - v1.9.3,
karma - v0.13.22,
gulp-angular-protractor - v1.1.1,
protractor - v5.1.2,
webdriver-manager - v12.0.6
Removing java-common and installing openjdk-8-jre fixed the issue for me.
To remove java-common and its dependencies, run below command
sudo apt-get purge --auto-remove java-common
To install openjdk-8-jre, run below command
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
Additionally, if you have more than one Java versions installed on your system. Run below command set the default Java
sudo update-alternatives --config java
and type in a number to select a Java version.
I'm running react-native init on osx and gets the following error:
You are currently running Node v0.10.30 but React Native requires >=4. Please use a supported version of Node.
But when running brew upgrade node it say: node 6.8.1 already installed.
Any ideas?
OK, had problems with the node installation. Finally uninstalled node by removing all related directories and running the following:
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh
I tried to install generator-angularjs using Yo (Yoeman) without sudo:
npm install -g generator-angular
I get:
Error: EACCES, mkdir '/usr/lib/node_modules/generator-angular'
When I type in sudo yo, yo tells me that I should not use sudo (which is perfectly understandable).
I have a ~/node_modules directory - why doesn't yo install its packages there?
Generators are designed to be installed globally. Otherwise, you always have to install the generator you're about to use in each project, which is unnecessarily painful. Also, you don't get to see the lovely yo menu which lists you all the available generators (unless of course, you install them all locally):
Setting up npm for global installation
So, how do we get npm to install packages globally? As you correctly said, you should never, ever run yo with sudo. There are lots of different solutions to this problem and you can spend hours discussing their pros and cons religiously.
I personally dislike installing my user packages into the global /usr/ folder. /usr/ is for software that is shared across all users on the computer. Even if it's only using the machine, there are still good reasons to respect the way the Unix file system hierarchy is designed. For example if you decide at one point to wipe your whole node installation.
My preferred way of enabling npm to install packages globally without breaking out of $HOME is to set a local node prefix. This is as easy as running
echo 'prefix = ~/.node' >> ~/.npmrc
in your local shell. After that, you want to adjust your $PATH, to point to the new installation destination for global node executables by adjusting your favorite shell's config. E.g. by adding
export PATH="$PATH:$HOME/.node/bin"
to your ~/.bashrc. After that, you can happily run npm install -g generator-angular without sudo, without running into permission conflicts and if something is completely broken and you want to start from scratch, all you need to do is remove your ~/.node directory.
Thanks to #passy I managed to finally get this working on ubuntu 13.04 (in case anyone is having similar set up issues) with the following :
sudo apt-get update
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
trying to run:
npm install -g yo
resulted in
Error: EACCES, mkdir '/usr/lib/node_modules/yo'
Fixed using:
echo prefix = ~/.node >> ~/.npmrc
echo 'export PATH=$HOME/.node/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
Running:
yo webapp
resulted in:
Error: EACCES, permission denied '/home/username/.config/configstore/update-notifier-yo.yml'
Fixed using:
sudo chown yourusername:yourusername /home/yourusername/.config/configstore/update-notifier-yo.yml
hi in my case (on ubuntu 12.04), the prefix addition in ~/.npmrc did not changed anything.
if so, build the node package by yourself and install it in /opt/node or /home/user/.node.
I had an almost identical error involving a rogue .yo-rc.json file in my root directory from a project I installed earlier. Yeoman was switching cwd from the installation dir to root dir half way through the installation, but was only outputting the EACCESS permissions error without any details that the installation directory was /. It took ages to figure out why this was, and involved debugging through the Yeoman source, but I eventually learned that Yeoman will look up through the directory tree until it finds a .yo-rc.json, and generate the code there by calling chdir to the new location.
Yeoman should maybe check that the user has write permissions for the directory. Alternatively, it could mention in the output either that the cwd has changed, or print the name of the installation directory if where it finds .yo-rc.json is different than cwd.
The command for finding rogue .yo-rc.json files
sudo find / -name .yo-rc.json
From yoeman getting started page appears the command:
yo doctor
In my case, $NODE_PATH (which in my case, Ubuntu 14.04, is defined in /etc/profile.d) isn't the same than npm root. Adding in npm root in $NODE_PATH solve the problem.
I have been trying to get yeoman to play nice with my vagrant box and this is what I had to do to install npm packages globally without sudo on ubuntu:
1. Create the directory to store global packages
$ mkdir "${HOME}/.npm-packages"
2. Tell npm where to put any packages installed globally
Insert this snippet into your ~/.npmrc file:
prefix=${HOME}/.npm-packages
3. Make sure that npm can locate installed binaries et cetera
Insert this snippet into your .bashrc/.zshrc:
NPM_PACKAGES="${HOME}/.npm-packages"
PATH="$NPM_PACKAGES/bin:$PATH"
// `unset` `manpath` to allow inheritance from `/etc/manpath` with
// the `manpath` command
unset MANPATH // remove this line if you have previously modified `manpath`
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
4. Run the following or restart terminal
$ source ~/.bashrc
Hope this helps anyone who finds themselves in a similar situation.
I wanted to install git with macports - it failed. ok. So I went with dmg - succeeded.
However, now I cannot remove git from some install queue and if I want install anything it still fetches git install command (which is failing btw).
so.. "sudo port install htop" still invokes "sudo port install git-core"
how to fix it?
htop uses a git repo. You have to install git-core first. Try this first:
sudo port clean git-core