How to create simple coffescript example without rails - node.js

I am new to coffeescript. I saw a coffeescript video in Rails casts.com. From that episode I understand how to convert the normal Js and Jquery to coffeescript code and the usage of coffeescript.
I am trying to create a coffeescript example without rails. I wetn through the coffeescript site. They first install Node.js. I tried to install node.js in windows and ubuntu, but I had failures. I followed the instruction as per this site:
http://howtonode.org/how-to-install-nodejs#ubuntu
For ubuntu I got "bash: ./configure?: No such file or directory" error when I execute the following command
./configure
Can anyone help me to create simple coffescript example without rails?
One more thing - In Mac "By the help of homebrew I can see the compiled js of coffescript code through compiled and Display Js window". Are there any options available in windows and ubuntu?

I would bet the easiest way to install Node.js on Ubuntu is through APT:
$ sudo apt-get install nodejs
It probably will get some outdated version but it can be enough for some tests.
If you prefer the latest version (which is a reasonable preference), I bet it would be easier to install Node.js from the dist package. Just copy and paste this on terminal:
wget http://nodejs.org/dist/node-v0.5.0.tar.gz && \
tar zvxf node-v0.5.0.tar.gz && \
cd node-v0.5.0 && \
./configure && \
make && \
sudo make install
This line will:
download the latest Node.js source code with wget http://nodejs.org/dist/node-v0.5.0.tar.gz
uncompress the downloaded source code with tar zvxf node-v0.5.0.tar.gz
enter into the source code with cd node-v0.5.0
set the build parameters with ./configure
effectively build the Node.js executable with make
install the built Node.js in your path with sudo make install
The && means "execute the next command if the previous command succeeds" (for example wget http://nodejs.org/dist/node-v0.5.0.tar.gz && tar zvxf node-v0.5.0.tar.gz means that we will download the package with wget and iff the download succeeds we will unpack the download file with tar. The backslashes (\) are here for allowing us to break all the series of commands in more than one line because, by default, we would have a big line:
wget http://nodejs.org/dist/node-v0.5.0.tar.gz && tar zvxf node-v0.5.0.tar.gz && cd node-v0.5.0 && ./configure && make && sudo make install
Then, you can install npm with this simple command, found in the own npm github page:
$ curl http://npmjs.org/install.sh | sudo sh
With npm, it will be too easy to install coffee, as you can see in the CoffeeScript page:
$ npm install coffee-script
Now, just run your tests:
$ coffee
coffee> a = key: 'value'
{ key: 'value' }
coffee> a.key
'value'
Does it look like to much work? You can try CoffeeScript in the language page. Just click in "Try CoffeeScript" and a console will appear to you.

For testing and demo purposes it may be sufficient to have your CoffeeScript compiled directly in browser. You can include the CoffeeScript compiler and your code in a tag.
This method is not efficient though so please use it for playing around.
Please see this section on how to set things up:
"text/coffeescript" Script Tags
Good luck!

Ubuntu 11.10 has an up-to-date package for CoffeeScript.
sudo apt-get install coffeescript

Related

Installing nodejs and npm on MSYS2

My OS is win7, and I using MSYS2(version:MSYS_NT-6.1), Please give advice how to install nodejs and npm on this terminal, Thanks!
I found a solution for resolving the problem,
64bit env.
pacman -S mingw-w64-x86_64-nodejs
32bit env.
pacman -S mingw-w64-i686-nodejs
after installed, Open terminal
$ node -v
v6.11.0
As of 2020, the package mingw-w64-x86_64-nodejs is not available any more. The simplest way to have Node.js, npm and git installed on a Windows machine is using the official Windows installers:
Git: https://git-scm.com/download/win
Node.js (npm is shipped with it): https://nodejs.org/en/download/
After installation, open a command prompt (click on start, and then type cmd and [ENTER]) and verify that all three tools are there:
git --version
node --version
npm --version
Later on, to update Node.js, simply reinstall it from the same source.
I wasted a lot of time on this. My solution is:
Download the Windows Binary (.zip) from nodejs site (https://nodejs.org/en/download/current/)
Extract it to some folder
Add that folder to the PATH env variable
It does work to use the Windows installer, and Node.js helpfully provides bash-script versions of npm and npx in C:\Program Files\nodejs\ to help streamline the process.
However, contrary to Cerclanism's comment # jmgonet's answer, you should not use --full-path with MinGW, no matter what terminal you're using, since that will by default bring the entire Windows path into your MinGW environment.
(Assuming you're a typical Windows developer with things like MSVC, Windows Python, and etc. install dirs on your path, containing plenty of names that clash with MinGW path members, you can see how that might bite you at some point down the road. My full Windows CMD.exe %PATH% is 1236 characters! I don't want all that sucked into MinGW.)
Instead, you should add the nodejs install dir to your MinGW shell $PATH, say by using everyone's favorite ~/.profile/~/.zprofile $PATH-munging trick:
# Append node.js to path
case ${PATH} in
*"/c/program files/nodejs"*)
;;
*)
export PATH="$PATH:/c/program files/nodejs:"
;;
esac
You'll probably also want to set some configuration, since by default Windows npm will use ${APPDATA}/npm for prefix, ${LOCALAPPDATA}/npm-cache for cache, C:\Windows\system32\cmd.exe for shell, etc.
# To view the full config including all defaults and overrides
npm config ls -l
# To view the active config for the specified environment
npm config list -L {global,user,project}
Maybe I was just confused, but to me it seemed, from what the configs show/say, that setting prefix= in my user config would override even local installs. (The project-specific ones where you npm install without --global, directly into a node_modules subdir of the current dir.) But after testing, happily I can report that's not the case, so it's safe to override the builtin prefix= from your $HOME/.npmrc.
Whether or not you move the cache= or let it stay at C:\Users\<you>\AppData\Local\npm-cache\ is your call. I'm sure it'll work that way. (Well, maybe not from an MSYS shell, but from MinGW it should be fine.)
There are minor differences I haven't overcome, but the only one that comes to mind right now is:
npm help <command> opens a browser window to HTML documentation, instead of displaying man page content directly in the terminal like it does on Linux. (Makes sense, as I don't think the manpages are even installed on Windows. Still disconcerting, though.)
You can simply install nvm, then install nodejs through there. In your MSYS2 shell just run the following to download and install nvm. Its better to go directly here and copy the download commands as the version numbers will change in the url.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
then run the following to setup nvm on your bash path:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
After running those commands you can use nvm install 16 or whatever node major version number you want. Type just nvm to get a list of available commands.

NPM and NODE command not found when using NVM

Seen other questions, but I think they are not my case.
I think the problem is over here, but I don't know how to solve it:
I do have latest Node version installed (I followed the official github page instructions)
> nvm install v7.3.0
v7.3.0 is already installed.
Now using node v7.3.0
I check node and npm versions installed
> which node
~/.nvm/versions/node/v7.3.0/bin/node
> which npm
~/.nvm/versions/node/v7.3.0/bin/npm
I check the PATH is right and it actually is
> echo $PATH
~/.nvm/versions/node/v7.3.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
But it still fails and when I browse through nvm folders... I find this, which I don't know how to change or solve:
> ls -a .nvm/versions/node
.
..
.DS_Store
v6.4.0 // WTF???
And I promise I didn't do anything, I mean... this is a clean install, .nvm folder didn't exist before installing nvm.
If you want to install the version you want in the place you want then you can follow my tutorial here on GitHub:
https://gist.github.com/rsp/edf756a05b10f25ee305cc98a161876a
It's about version 6.7.0 but you can change it to any other version. It show you how to install either from source or from binary packages and following that tutorial you will always know which version is where, because you have full control over the installation instead of relying on tools that do that automatically for you.
If you want to have Node 7.3.0 in /usr/local for example the it is just:
wget https://nodejs.org/dist/v7.3.0/node-v7.3.0.tar.gz
tar xzvf node-v7.3.0.tar.gz
cd node-v7.3.0
./configure --prefix=/usr/local
make && make test && echo OK || echo ERROR
sudo make install
Edit .bash_profile using the below command.
nano .bash_profile
And add the following lines to .bash_profile
export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh
Save it. Exit the terminal and check the magic.

Installing nodejs: I need GNU make. Please run 'gmake' instead

I want to install nodejs on my PCBSD 10 system. I have downloaded the src file of latest nodejs. On terminal I ran the command ./configure It runs fine. After that I tried make but its asking on console
I need GNU make. Please run 'gmake' instead.
Then I tried gmake the terminal says
CORRECT>gmake (y | n | e | a)?
I pressed y then again it says "I need GNU make. Please run gmake instead"
How to install nodejs???
If you install it using the FreeBSD ports system, that will take care of these details for you.
If you haven't installed the ports tree, run the following command as root;
svnlite checkout https://svn0.us-west.FreeBSD.org/ports/head /usr/ports
Note that there are some subversion mirrors for FreeBSD. Choose the one closest to you. After the initial checkout, you can update the ports tree by running the following command as root;
svnlite update /usr/ports |& less
When the ports tree is installed and up-to-date, you can install node by running the following commands as root:
cd /usr/ports/www/node
make install clean
This will first install the ports that node depends on (gmake and python2) and then node itself.
You might also want to install the node package manager from the www/npm port.

Install Node.js to install n to install Node.js?

I have a problem understanding the use of n. Basically, it is clear that it is a version manager for Node.js such as nvm.
But in contrast to nvm, which is basically a shell script, according to the documentation you are encouraged to use npm to install n:
$ npm install -g n
What I don't get is: For having npm at hand you need to install Node.js. Why would I install Node.js manually to use npm to then be able to install Node.js using n?
To put my question in other words: Why does n suggest installing using npm, if its main purpose is to install Node.js, which includes npm?
tl; dr
# Installs n and the latest LTS Node.js version to ~/n.
# For bash, ksh, zsh, modifies the respective user-specific shell-initialization file to
# define env. variable N_PREFIX and append $N_PREFIX/bin to the $PATH.
curl -L https://git.io/n-install | bash
I feel your pain. Installing Node.js to then install n to then manage Node.js installations is indeed a strange setup.
It would indeed be great to be able to install n by itself first.
I've created a project to support installation of n directly from GitHub; the only prerequisite beyond what n itself needs is git.
Note that you must first remove any pre-existing n / Node.js versions.
The target directory, ~/n by default, must either not yet exist or be empty.
For bash, ksh, and zsh, the relevant shell initialization file (e.g., ~/.bashrc) is automatically modified to define environment variable N_PREFIX and append $N_PREFIX/bin to the $PATH; for other shells, this must be done manually.
Aside from installing n directly from GitHub, it also installs helper scripts for updating n (n-update) and uninstalling it (n-uninstall).
Here are working examples; see the n-install GitHub repo for details:
Installation with confirmation prompt to confirm installing to default location $HOME/n and installing the latest LTS Node.js version:
curl -L https://git.io/n-install | bash
Automated installation to the default location, with subsequent installation of the latest LTS (long-term support) and latest-overall Node.js versions, as well as the latest 4.1.x Node.js version:
curl -L https://git.io/n-install | bash -s -- -y lts latest 4.1
Automated installation to the default location, without subsequent installation of a Node.js version:
curl -L https://git.io/n-install | bash -s -- -y -
Automated installation to custom location ~/util/n, with subsequent installation of the latest LTS Node.js version:
curl -L https://git.io/n-install | N_PREFIX=~/util/n bash -s -- -y
If you prefer, you can install n from source:
cd /tmp
git clone --depth=1 https://github.com/tj/n
cd n
sudo make install
Then you can install the latest stable version of node as follows:
n stable
The n module was created for convenience.
For example, if you wanted to update your version of Node.js from v0.8.0 to v0.10.20, would you rather download a package, extract and compile? Or would you rather type n 0.10.20 and have it instantly installed, while still retaining previous versions of Node for easy switching?
n suggests using npm to install it because n is a module. That is, npm is the easiest way to install it. Node modules have the functionality of being able to run in a shell when installed globally, so that function was utilized to make switching Node versions much easier.
You can also install npm separately from Node.JS; e.g.: on a system without Node.JS:
git clone https://github.com/npm/npm
cd npm
./configure
make
Reference: NPM GitHub project
I had the same question, but have seen the light. 'n' is a handy tool and makes it simple to test different versions of node. Works great on Linux, but no matter how I try to install it on OS X (git clone, then npm install or using user456584's recommended method), when I run it, I always get the same results of "Error: no installed version", even though it installs into
/usr/local/lib/node_modules/n
and
/usr/local/bin/n
Frustrating because I've found this tool to be so handy on Linux.
If you have included your default node bin in the $PATH variable like this
export PATH=/usr/local/Cellar/node/11.5.0/bin:$PATH
then n will not be able to active other node versions. Remove this export from the path and then you can manage the currently active node version by n.
The README for n now has a longer section covering different installation approaches.
Like nvm, n is a bash script. npm is suggested as an easy way to install n if you already have npm, and then you can use n to change the Node.js version. But there are plenty of other approaches for a first install of Node.js. In brief and in no particular order...
You can install n using curl:
curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n
Or clone the n repo and install from there:
make install
Or use n-install:
curl -L https://git.io/n-install | bash
Or Homebrew:
brew install n
Or MacPorts:
port install n
(Disclaimer: I am the current maintainer of n.)
If you are using n then you should use below command
bash$ sudo n latest

Where should I install node.js?

I'm wondering in which directory I should go to install node.js on a CentOS 5/cPanel server by executing the following commands mentioned in the Wiki:
git clone --depth 1 https://github.com/joyent/node.git
cd node
git checkout origin/v0.4 # optional. Note that master is unstable.
export JOBS=2 # optional, sets number of parallel commands.
mkdir ~/local
./configure --prefix=$HOME/local/node
make
make install
echo 'export PATH=$HOME/local/node/bin:$PATH' >> ~/.profile
source ~/.profile
Please advise.
The more conventional locations for a multi-user system are:
/usr/bin/node
/usr/local/bin/node
But as #Raynos stated you can put it wherever you want to.
I like to install latest version of node.js using something called nvm.
Like Raynos said you are better of using node v0.4.8 instead of development branch to avoid broken packages.

Resources