I have untarred node.js from the tar file given on nodejs.org, but when i try executing my js program through node command nothing happens, but on the other hand nodejs command runs executes the file.
So my question is what's the difference between node command and nodejs command as and will it effect my programs as i didn't build from the source code. And i of that is the reason of this discrepancy.
This is highly dependent on many factors. Mainly, it depends on what node and nodejs in your shell actually are. You can check this using type node / type nodejs and/or which node / which nodejs (or perhaps whereis). This also depends on the OS and the shell.
My guess is that which -a node will yield /usr/sbin/node which is not the nodejs executable and thus why it does not execute your node code. On my system, it is:
/usr/bin/node -> /etc/alternatives/node -> /usr/bin/nodejs
i.e. node is just a symbolic link to nodejs, which is the executable.
You can also create this alias yourself so that it overrides whatever node is for you.
Some of these answers were difficult to understand for me, so I'm going to write the answer that would've helped me.
node is something like a radio telemetry solving program, they just happened to snag the name node first. nodejs is what you're after. So
make sure you:
apt-get install nodejs
then, to fix the lame naming issue, create a symlink. A symbolic link between node and nodejs.
sudo ln -s /usr/bin/nodejs /usr/bin/node
The first part is the original file placement, and then where it should link to.
You could also create an alias in your bash profile, which is also pretty easy.
For sure available 'node' package is not related to nodejs.
Just take a look at this node from here:
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
There is a naming conflict with the node package (Amateur Packet Radio Node Program), and the nodejs binary has been renamed from node to nodejs. You'll need to symlink /usr/bin/node to /usr/bin/nodejs or you could uninstall the Amateur Packet Radio Node Program to avoid that conflict.
So it seems like you may purge that radio program with
dpkg --purge node
And then install nodejs via one of common ways f.e. from precompiled deb packages available like this:
sudo apt-get update
sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
But nodejs updates faster than packages so after you will get any nodejs version available it's more efficient to use this module for managing nodejs versions - https://github.com/visionmedia/n
At least after some tests this solution looks most suitable for me at mac os.
Related
In my ec2 instance I am able to run pm2 command.
But while deploying application through code deployment I get this error.
LifecycleEvent - ApplicationStop
Script - application_stop.sh
[stdout]Stopping any existing node servers
[stderr]/opt/codedeploy-agent/deployment-root/878477e5-6ffb-4175-8e9e-97045ea99290/d-HVRQ58IBL/deployment-archive/application_stop.sh: line 4: pm2: command not found
My application_stop.sh code.
#!/bin/bash
#Stopping existing node servers
echo "Stopping any existing node servers"
pm2 stop main
As per #ranjanistic I checked my pm2 path using which pm2 command and it returned
~/.nvm/versions/node/v16.15.1/bin/pm2
After that I update my application_stop.sh using this below command
~/.nvm/versions/node/v16.15.1/bin/pm2 start main
Also added symbolic link like this to npm, node and pm2.
///this process worked. Thanks #ranjanistic
which npm
which node
which pm2
sudo ln -s /home/ec2-user/.nvm/versions/node/v16.15.1/bin/npm
sudo ln -s /home/ec2-user/.nvm/versions/node/v16.15.1/bin/node
sudo ln -s /home/ec2-user/.nvm/versions/node/v16.15.1/bin/pm2
Still not working
The binary executable reference to your command needs to be available in the environment you're expecting to run it from.
You are using npm to run a pm2 command, which means it is installed as a local module. Therefore you can similarly create another npm script like npm run stop:all with your pm2 command, it should work.
If you're running it in a bash script, the command reference binary should be available in PATH. Or you can also use your command by mentioning its binary path instead of name, independent of wherever the binary is located, for example
If pm2 is installed as a global node module
/usr/bin/pm2 stop main # or whatever the path to the binary is.
Or if pm2 is installed as a node module in project then
./node_modules/bin/pm2 stop main # again, path to pm2 binary can be anything, you'll have to know beforehand
Also, I'd recommend a separate config file for each of your pm2 applications, so that you can use it anywhere without worrying whether your main app is available to pm2 or not.
You may also need to check if npm or node commands are running or not, and based on that you may add the path to your folder containing pm2 in $PATH variable before running the deployment. You can check the path to pm2 manually using which pm2 if it is available.
You need to provide absolute path like this /usr/bin/pm2
I've been creating a JavaScript game for a project recently and have done it completely on the CodePen website. I now am trying to transfer it to WebStorm to turn it into a basic website. However when I try to run my code I get the following error:
I don't know how to fix it, I've looked everywhere and haven't been able to get some help. Any information would be appreciated.
Simple one, basically the error says, I don't know how to interpret this bit of code that you just gave me. You're missing local install of Node.js and NPM. Get the latest versions of these 2, and then go to File -> Settings -> Language&Frameworks -> Node.js and NPM and in the Node interpreter text box, point it to the path of where node.js was installed.
You're running this JavaScript file with Node.js that is probably not installed on your machine. It seems that you want to run and debug your app in the browser instead. For that you need to create a JavaScript run/debug configuration instead as described here: https://www.jetbrains.com/help/webstorm/debugging-javascript-in-chrome.html
On a linux machnie,
Install nodejs and npm
sudo apt-get install nodejs
sudo apt-get install npm
Get the nodejs installation folder
whereis nodejs
Should print something like:
/usr/bin/nodejs /usr/lib/nodejs /usr/include/nodejs /usr/share/nodejs /usr/share/man/man1/nodejs.1.gz
Go to:
Webstorm-> File -> Languages & Frameworks -> Node interpreter
Copy paste the installation folder to the text box.
Mac OS here. Solved the issue with:
$ brew install nodejs
So Y!Pipes is shutting down, no real alternatives exist, especially none quite similar to Y!Pipes.
WebHookIt, here for the sources, seems like a potentially good alternative, keeping the simplicity of Y!Pipes' interface, and quite a potential to do what Y!Pipes does, and more: open-source, javascript generator (allowing to host "pipes" on google scripts for example).
However, that's a project that was launched a few years ago, and the dev left soon thereafter. There is work to be done on it, and the user documentation is next to non-existent.
I know SX is absolutely not a forum but I'd like to use this very generic question: "anyone to help me update and complete WebHookIt?" to gather all contributions on it. If it takes, we'll move on to a fork on github.
WebHookIt is coded in javascript using node.js. I can code a bit in javascript, but I'm a newbie regarding node.js (though I'll be very invested in the project for the time being, and I'll begin by getting on page with node as soon as tomorrow).
I'll start with the installation, for *buntu systems:
First the dependencies: npm (node.js installer), node.js, and mango-db:
npm:
install: sudo npm install npm -g
check install with npm -v
you will probably run into trouble later when trying to install webhookit (or anything I think) over the ownership of npm, as I did, if you don't claim it. Hence that generic enough command: sudo chown -R $(whoami) $HOME/.npm
node.js
taaem has made a script to download the latest node and satisfy dependencies. Download "node-install.sh".
make it executable: chmod +x node-install.sh
execute it: ./node-install.sh
follow instructions.
mango-db: follow instruction on their install page. Herein reproduced:
add mango-db repository key: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
add repository to the sources: echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
update package database: sudo apt-get update
install mango-db packages: sudo apt-get install mongodb-org*
start mango-db service (it should already be started): sudo service mongod start
WebHookIt is installed by first downloading the repository on github. Now, if you try to install right away you'll run into trouble. This is an old project (latest commit is 3 years old), and the developer didn't provide for improvement to npm. Hence the following steps:
download the sources. With git installed: git clone git://github.com/neyric/webhookit.git
go into the webhookit folder, just created, and edit "package.json". Here is the list of the required dependencies, amongst other info about the program.
find the npm line (should be the 27th), and add ">=" before the version number. End result is: "dependencies": { ... "npm": ">=1.1.0-2", ... },
install! When into the "webhookit" folder, execute: npm install .
a few warnings will pop up, from node being more recent than required by the dependencies. As node is still in the same major version, it shouldn't be a problem (if well developed, a software shouldn't have compatibility problems within a given major revision (eg the first number)).
start webhookit server! node server.js
start using it, in your web browser, by default at http://localhost:8124
Next step is to figure out what it means when it says "Open a wiring first."...
I have to set-up node environment in my production system. I installed node in my local system its fine, after that i checked for version node -v.
Now i installed node in my production system using sudo apt get install nodejs and now i checked the version node -v nothing happened but i used nodejs -v, its working.
Also in my local system i used node filename.js to run my node app. But in my production system i have to use nodejs filename.js. I dont know why this happening? Also whether it will create problem in my production. Please share your ideas.
It's more linux specific question. You can create a symlink to use node instead of nodejs. Command example here:
sudo ln -sT $(which nodejs) /usr/local/bin/node
This is because your particular distribution of linux already has a node binary.
You're more than likely not using it for anything. You have two options.
rename the pre-installed node to something else, and rename nodejs to node
rename nodejs to node but make sure to adjust your $PATH so that node.js's directory is loading before the pre-installed node
I created a new Rails project using rails 3.1.0.rc4 on my local machine but when I try to start the server I get:
Could not find a JavaScript runtime. See here for a list of available runtimes. (ExecJS::RuntimeUnavailable)
Note: This is not about Heroku.
Installing a javascript runtime library such as nodejs solves this
To install nodejs on ubuntu, you can type the following command in the terminal:
sudo apt-get install nodejs
To install nodejs on systems using yum, type the following in the terminal:
yum -y install nodejs
Note from Michael 12/28/2011 - I have changed my accept from this (rubytheracer) to above (nodejs) as therubyracer has code size issues. Heroku now strongly discourage it. It will 'work' but may have size/performance issues.
If you add a runtime, such as therubyracer to your Gemfile and run bundle then try and start the server it should work.
gem 'therubyracer'
A javascript runtime is required for compiling coffeescript and also for uglifier.
Update, 12/12/2011: Some folks found issues with rubytheracer (I think it was mostly code size). They found execjs (or nodejs) worked just as well (if not better) and were much smaller.
n.b. Coffeescript became a standard for 3.1+
Add following gems in your gem file
gem 'therubyracer'
gem 'execjs'
and run
bundle install
OR
Install Node.js to fix it permanently for all projects.
sudo apt-get install nodejs does not work for me. In order to get it to work, I have to do the following:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Hope this will help someone having the same problem as me.
On the windows platform, I met that problem too
The solution for me is just add
C:\Windows\System32
to the PATH
and restart the computer.
I had this issue on a Windows machine and installing node.js was the solution that finally worked for me. This came after trying multiple other routes including trying to get 'therubyracer' working. Though the github for node.js suggests that installation on windows is still unstable, the website at http://nodejs.org/ had a Windows installer which worked perfectly.
if you already install nodejs from source for example, and execjs isn't recognizing it you might want to try this tip: https://coderwall.com/p/hyjdlw
If all fails you can try
# aptitude install nodejs
as root. You can test your install with the following command:
# node -v
If you want to install NPM, please refer following link. Hope it helps.
On CentOS 6.5, the following worked for me:
sudo yum install -y nodejs
Install a Javascript runtime
The error is caused by the absence of a Javascript runtime on your local machine. To resolve this, you'll need to install NodeJS.
You can install NodeJS through the Node Version Manager or nvm:
First, install nvm:
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
Install Node through nvm:
nvm install 5.9.1
This will install version 5.9.1 of Node.
I ran into this issue using Phusion Passenger (running as an nginx module) on a Redhat server. We already had a Javascript runtime installed. Other Rails apps in the same parent directory worked fine.
It turned out that we had a permissions issue. Run "ls -l" and see if the folder has the same owner and group as other working apps on the system. I had to run chown and chgrp on the folder (with the recursive switch) to fix it.
I hope you have pre-installed nodejs || nmv.
My solution does not require gem setup or installing 'node with sudo apt" when you already have nvm.
All you need is to edit DesctopEntry of RubyMine. for that we will have those small steps:
Go to usr/share/applications
Open in any editor (i use vim ) Rubymine DesktopEntry vim RubyMine
Edit line 6 (starts with Exec). You shoud add to beginning /bin/bash -i -c. So your line should look like this
Exec=/bin/bash -i -c "/home/USERNAME/rubymine/RubyMine-2019.1.2/bin/rubymine.sh" %f
Done! You are glorious!
As a benefit all your environment variables are now available for RubyMine. So you feel no pain with additing them.
On MacOS try running:
brew install node
brew link node
To force the link and overwrite all conflicting files:
brew link --overwrite node
node -v