I'm not familiar with Ubuntu. I want to make some nodejs apps for testing, now I'm confused where I should create a directory for it.
I have searched in google and I found every one saying
sudo apt-get install nodejs npm
and create server.js
file and put this code blah blah
and run npm server.js
etc.
But where I should create this file? Where I should create directory?
I know about /var/www/html
but there are my other php projects here.
For development use a subdirectory if your user home dir.
E.g., ~/projects/test-project
like somebody suggested.
You would usually add this to git, too. E.g.
mkdir -p ~/projects/test-project
cd ~/projects/test-project
# add your server.js now
git init
git add .
git commit -a -m 'here goes nothing'
For testing, you might wanna do something closer to what your deployment site looks like. Usually it's /srv/project-name
or /var
like you've suggested.
Those directories usually don't exist and you cannot access them by default, so you create them with sudo. Example:
sudo mkdir -p /srv/my-project
sudo chown `whoami`:`whoami` /srv/my-project
cd /srv/my-project
git clone ~/projects/test-project .
Now you can test both local dev version and the test one.
P.S. You should try nvm.sh for installing node, much more versions and fresher ones.
You can place the projects anywhere you like. I usually put them in ~/projects.
Running npm start
will fire up a web server running at http://localhost:8080, so there's no need for /var/www if you're just doing some testing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With