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
Related
Using node.js, I wanted to create a kiosk application with a RFID Reader attached to the kiosk. In order to access my RFID Reader, I installed the node-hid library (https://github.com/node-hid/node-hid). However, when I tried to run the application, an error occured, says:
Uncaught Exception
Error: The module 'D:\Projects\Electron\SelfService\node_modules\node-hid...\build\HID.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 72. This version of Node.js required NODE_MODULE_VERSION 73.
I already updated the library and the node.js version to the latest update, but since the library is kinda old, it doesn't get any more update.
I tried to downgrade the node version, however there aren't any helpful tutorial I can find out there. I know there are many tutorial that explained how to install the older version of node, but I can't simply know what version of node I need from the error message displayed above.
I need to get the device readable by the application. If somehow, it's impossible to use the node-hid library, what is the latest library you recommended to access the RFID Reader from the application?
Note: I'm familiar with web development, including Javascript language, but Node.js is a new experience for me. I'll try my best to provide informations regarding my project, but if there are some mistakes with how I described my problem or if I have some difficulties in understanding your answers, please bear with me.
EDIT: I forgot to mention I'm on Windows 10, the node version I installed is 10.16.3
First Try this command -
Uninstall the electron first then try below command
sudo npm install --save-dev electron#4.0.0
sudo npm i --save-dev electron-releases#4.0.0
And also try to update chrome
Above is solution be sure minimum using Linux 16.04 with x64 processor and for npm version change see below
For NPM Version Downgrade of Linux/Ubuntu
sudo npm install -g npm#version
example-
sudo npm install -g npm#6.9
For Windows - start command prompt administrator
npm install -g npm#version
example-
npm install -g npm#6.9
You can uninstall the current node and then re-install the desired node version.
But the best practice will be installing node.js using the nvm aka node version manager.
Using nvm you can easily switch between different node version as well as different npm version.
Here's a quick start for installing node using nvm in both
windows, linux and unix platform.
NVM Official doc for unix and linux.
NVM alternative for windows
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
I am trying to set up the JavaScript code tester Karma, but when I run the command to initialise karma I get the error 'usr/bin/env: node: No such file or directory'. How can I fix it?
As per #digitalmediums
I've found this is often a misnaming error, if you install from a package manager you bin may be called nodejs so you just need to symlink it like so "sudo ln -s /usr/bin/nodejs /usr/bin/node"
sudo ln -s /usr/bin/nodejs /usr/bin/node
this worked for me.
node is a reserved term in ubuntu thus node.js is actually nodejs.
I found a similar question with same issue here
Usually the non packaged node version (not nodejs) that the user installs can be run from /usr/local/bin/node
as
#!/usr/local/bin/node
I am currently working on JavaScript and want to design unit test for JavaScript I am using google-JS-Test
http://code.google.com/p/google-js-test/
I have downloaded gjstest-1.0.7
I have installed all the prerequisites need.
http://code.google.com/p/google-js-test/wiki/Installing#Prerequisites
but when I install google js test using
$ cd gjstest-1.0.7
$ make
I got following errors
g++ -DHASH_NAMESPACE=__gnu_cxx -lrt -I. -I/usr/include/libxml2 -DDEFAULT_DATA_DIR=/usr/local/share/gjstest -c -o gjstest/internal/cpp/v8_utils.o gjstest/internal/cpp/v8_utils.cc
gjstest/internal/cpp/v8_utils.cc:33: error: ‘v8::StackFrame’ has not been declared
gjstest/internal/cpp/v8_utils.cc:34: error: ‘v8::StackTrace’ has not been declared
gjstest/internal/cpp/v8_utils.cc: In function ‘void gjstest::ConvertToStringVector(const v8::Handle<v8::Value>&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >*)’:
gjstest/internal/cpp/v8_utils.cc:60: error: no matching function for call to ‘v8::Array::Get(uint32&)’
/usr/include/v8.h:1161: note: candidates are: v8::Local<v8::Value> v8::Object::Get(v8::Handle<v8::Value>)
make: *** [gjstest/internal/cpp/v8_utils.o] Error 1
It seems like v8 is not install correctly
I have installed V8 using commands like
sudo apt-get install libv8-2.0.3
sudo apt-get install libv8-dbg
sudo apt-get install libv8-dev
And also by downloading it
svn checkout http://v8.googlecode.com/svn/trunk/ v8
cd v8
make dependencies
scons
But still getting these errors
So if any one has installed and used Google Js or installed v8, kindly guide me on how should I solve this problem.
I am using Ubuntu 10.04.
Any help will be appreciated.
This is indeed caused by trying to build gjstest against a very old version of libv8.
I checked out and built a more recent libv8 on ubuntu 10.04 by following the instructions here:
svn checkout http://v8.googlecode.com/svn/trunk/ v8
cd v8
make depdendencies
make native library=shared
cp out/native/lib.target/libv8.so /usr/local/lib/libv8.so
cp include/v8.h /usr/local/include/v8.h
cp include/v8stdint.h /usr/local/include/v8stdint.h
After which gjstest compiled and ran without further surprises.
What is an easy-to-use free JavaScript minifier running in Ubuntu?
It should be easy to install as well. ;-)
I'm using the YUI Compressor
Check JSMin:
https://bitbucket.org/dcs/jsmin/
Install it with:
sudo apt-get install python-pip
sudo pip install jsmin
Usage as CLI:
python -m jsmin myfile.js
For example:
python -m jsmin large1.css large2.css > minified.css
As library:
from jsmin import jsmin
with open('myfile.js') as js_file:
minified = jsmin(js_file.read())
Use Closure Compiler
Documentation: Getting started
I recommend using some Javascript task runners such as Grunt or Gulp, if you dont want to use any task runners, just install Node in your ubuntu by
git clone https://github.com/joyent/node.git
cd node
./configure
make
sudo make install
Once the installation is complete
Just install a package called "minifier" via NPM ( node package manager )
npm install -g minifier
g in the above command is to make this package available globally throughout the system .
Once the installation is complete you can just run the below command to minify your javascript.
minify --output path/to/output/file path/to/inputfile
Some times using Google Closure compiler, creates lot of problem, Since it throws lot of compiler errors by checking against standards,But still it does a great job, sometimes we will not be in a position to fix those ECMA standard issues displayed by google closure. :)
Hope this post helps other folks who are facing similar issue.