Where can I find node.js interpreter - node.js

In WebStorm to get karma.conf running I need to configure it in a pop up window and enter the "path to the node.js interpreter".
(for some reason this information vanished after a restart)
Questions:
What is the path to the needed file?
Where is the node interpreter on Mac/Linux/Windows by default?
(I am on OS X)

Generally, on OSX and Linux, you can find any program with which program. In your case, type
which node
in terminal.

On windows command prompt
where node

On OSX if you've installed Node.js with brew:
/usr/local/bin/node
You can check the exact folder on your machine with the command which node
Important
When the finder opens on OSX, you won't be able to navigate to this path initially. You'll first need to navigate to the root folder e.g. Macintosh HD and then perform the keyboard shortcut Command + Shift + . (. = dot = period) to be able to select hidden files and folders.

Ubuntu:
sudo apt install nodejs
whereis nodejs
nodejs: /usr/bin/nodejs /usr/lib/nodejs /usr/include/nodejs /usr/share/nodejs /usr/share/man/man1/nodejs.1.gz
Configuring NodeJS Intepreter in IntelliJ:
File | Settings | Languages & Frameworks | Node.js and NPM
Node interpreter: Add... (select from the above path or add it)
/usr/bin/nodejs
Then, click on Enable button and select the modules.

On OSX:
/usr/local/bin/node
well I got it by myself, but wanted to share the answer, as I couldn't find it on google / stack overflow and hope to save somebody some time

This can be useful for someone. I tried all the previous methods on Linux Ubuntu 19.10, none worked, neither reinstalling nodejs. So I installed Webstorm via snap, with:
sudo snap install webstorm
sudo snap install webstorm --classic
And surprise, Nodejs was already configured in this version. Then I erased the webstorm version that I installed from Ubuntu Softwared.
That worked for me and was easy. Hope that can give you a clue.

Related

Neovim COC - "node is not executable"

(I am using ubuntu 18.04 WSL2 on the Windows 10 terminal emulator)
Hello, i am having problems with coc on Neovim. The coc plugin is installed correctly (with vim-plug), but when i started nvim a massege would appear "node is not executable", so, i changed the path in the init.vim folder, "let g:coc_node_path = 'C:/nodejs/node.exe'", but now another erro message appears " "C>/nodejs/node.exe" is not executable ", does someone know how to fix that?
My "init.vim" file and "plug-config" folder: https://github.com/user-d4ba/Files
In case anyone has my situation. I had node installed with node nvm/npm. The error never happened when I started nvim from the command line, only from the Application Menu (in KDE).
I got node's path with:
$ nvm which current
Then in init.nvm which was in ~/.config/nvim:
let g:coc_node_path = 'path'
You may not have installed node. Check to make sure you have - if you haven't, you can find install instructions and binaries on their GitHub, or use an applicable package manager if you prefer.
You can also reinstall it if you are not sure.

Npm command not found in visual studio code

Please tell me how i can solve it. Iam using window 7 32 bit:
By default, Visual Studio Code runs shell commands like npm in a loginless shell. If you installed NVM, Visual Studio Code may have no indication where to find npm to run it.
Put the following lines are in .bash_profile: (Note: Not .bashrc.)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Add this setting to settings.json:
"terminal.integrated.shellArgs.linux": ["-l"]
On Mac OS , I switched to the zsh and got this fixed. These following steps fixed the issue :
On your VsCode in Mac : shift + command + P .
On the Prompt > type : Terminal: Select Default Profile , then "Click it". Note, as you type you will find this option in the auto-complete .
Click the option for zsh or your desired shell.
Restart VSCode .
now npm will work in your vscode terminal.
I too had this issue.
To solve this follow the below steps.
Make sure you have npm installed
- go to command prompt & type npm -v
- if a version comes out it's installed, else go to https://nodejs.org/en/ and download same.
Then come to vs code and set deafult shell to cmd.
to do so,
- Press Ctrl+Shift+P and type Select Default Shell
- Select Command Prompt.
- Press Ctrl+`
- Type npm -v and see npm works. :)
I got this error after having just installed nodejs/npm, and the way i resolved, while still being able to use git bash terminal in vscode was to simply restart my computer (I hadn't done this after node installation).
I needed to kill the terminal in VS Code and restart a new terminal to get npm to show as installed.
As you're aware, you can configure your environment variables in windows at 2 levels.
At user level
At system level
When VS code is started, it picks the variables in path at a user level and not at system level because you haven't run the application as Administrator.
Just copy-paste your node path from System Variables to User Variables
This does the trick for windows.
Thanks.
If you just installed your node while your VScode was running. Restart your vscode it should start working.
You need to install npm first, https://www.npmjs.com/get-npm and make sure npm command is accessible using terminal/command prompt.
You can also use https://marketplace.visualstudio.com/items?itemName=eg2.vscode-npm-script This extension supports running npm scripts defined in the package.json file and validating the installed modules against the dependencies defined in the package.json.
On mac, I switched the default shell from bash to zsh and it fixed the issue.
I'm gonna add an answer just for help others because this question is 2 years old.
If you can run the npm start (NPM SCRIPTS below the Explorer view) but you are not able to launch the command with a shortcut: Then check npm extension is installed and/or enabled for the current workspace/folder.
Otherwise vsCode will not be able to run the script and you're going to get a message in a little box like this
command 'npm-script.start' not found
Maybe the NPM Scripts View below the explorer is not available without the plugin I'm not sure
For me, restarting VS code and even my PC didn't work, but after restarting VS code via "reload" (not restart, not refresh) from ctrl+shift+P, then in the top right of the terminal clicking the leftmost button and clicking "kill terminal" then restarting VS code it worked.
I had this issue too and I'm running QubesOS which uses virtualization.
I could manage to get it running until I'd a standalone VM.
That solved my problem.
Just mentioning for the ppl using virtualization like virtual box or VMware.

Using sudo atom no longer opens Atom at all, let alone as root

I'm using the Atom editor. Yesterday, if I typed:
sudo atom . it opened the current directory as root
sudo atom it opened Atom with whatever I last had open as root
Today if I run either of those commands nothing happens. The editor doesn't open and there are no error messages.
These terminal commands worked yesterday on these exact same files, today they do not.
How can I fix this?
Why is this happening?
If I have not provided enough information it's because I don't know what info one would need to have a fuller explanation of my circumstance. Let me know what I should add I'll happily edit this question to provide it.
Atom : 1.13.0
Electron: 1.3.13
Chrome : 52.0.2743.82
Node : 6.5.0
Ubuntu 14.04 LTS
Elementary OS Freya (64-bit)
After updating Atom text editor it seems I require to run --no-sandbox flag but after a while it becomes boring so I wrote a simple BASH script to be doing this for me:
eval "atom --no-sandbox flag"
just save this in a common directory that you frequently use and type ./atom_text_editor.sh in the terminal to deploy(Depending on the name you choose for your script)
A recommendation, when working on linux avoid using sudo or su instrucctions, they are intended to execute privileged instructions like system configurations. It might be related to permissions, execute ls -al and verify that the owner/group of yor files is root, if not, then check if "others" have read permission, if not, then thats is the problem.
Be aware running atom with sudo is not recommended.
I've had this problem for a few days, I installed atom using snap (on ubuntu 18.04) a few weeks ago, back then it worked perfectly, but the last few days if i ran 'sudo atom' nothing would happen at all, reinstalled it using snap, still didn't work, removed settings, still didn't work.
I ended up installing atom using the apt packagage manager and now it works. I used this guide: https://codeforgeek.com/install-atom-editor-ubuntu-14-04/
Furthermore when running atom with sudo it should be ran with the --no-sandbox flag.
Conclusion: seems to be a problem with atom when installed using snap.

Warning: node.js detection failed, sbt will use the Rhino based Trireme JavaScript engine

I'm new to Play framework. Please explain the meaning of the below warning.
Warning: node.js detection failed, sbt will use the Rhino based Trireme JavaScript engine instead to run JavaScript assets compilation, which in some cases may be orders of magnitude slower than using node.js
I don't want anything that slow down my application so please advice if I should change the JS Engine to Node.js, but my PlayFramework project is using Java on the server side.
You need to install Node.js and then tell the sbt/java engine to use it.
brew install node
Edit .bash_profile and add:
export SBT_OPTS="${SBT_OPTS} -Dsbt.jse.engineType=Node -Dsbt.jse.command=$(which node)"
This eliminated the warning for me on OSX
In Windows:
Install node.js
Go to Control Panel - System and Security - System - Advanced system settings
Click Environment Variables...
Search in System variables for SBT_OPTS
If such exists, click Edit... and concatenate -Dsbt.jse.engineType=Node to Variable value
If such does NOT exist, click New... and write SBT_OPTS to Variable name and -Dsbt.jse.engineType=Node to Variable value
Click OK - OK - OK
Restart any command prompt (cmd, PowerShell) that is currently running Play Framework
in ubuntu
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
then add as above to your .profile in your home directory
export SBT_OPTS="${SBT_OPTS} -Dsbt.jse.engineType=Node -Dsbt.jse.command=$(which node)"
then
. ./.profile
to reload your .profile
For a more flexible install using node version manager check the following tutorial:
how to install node js on an ubuntu 14.04 server
Build again and the warning about using the Trireme stuff should be gone.
As an alternative to setting the environment variable, you can add this line to your build.sbt file:
JsEngineKeys.engineType := JsEngineKeys.EngineType.Node
See: https://github.com/sbt/sbt-js-engine
sbt plugins requiring a JS engine are used only in the build process, and so missing Node.js only slows down assets building stages if you use any.
The built application is not affected.
Anyway, you may want to install node.js to your PATH, where it should be auto-detected.
in Windows 10:
Install node.js from https://nodejs.org/en/
(The installer automatically adds node.js to your PATH)
then add:
export SBT_OPTS="$SBT_OPTS -Dsbt.jse.engineType=Node"
to your plugins.sbt in
. ./project/plugins.sbt
Worked for me - the warning has disappeared!
EDIT:
Apparently plugins.sbt was the wrong place to add the
export SBT_OPTS="$SBT_OPTS -Dsbt.jse.engineType=Node"
...although the warning disappeared when loading my app, it led to an error when relaunching the app a couple of hours later:
error: not found: value export
I would be glad if anyone could help and tell me where to put the export.

Node.js Cygwin not supported

I am trying to install node.js. I followed this tutorial and i am stuck in the middle.
When I write ./configure in my cygwin terminal it says "cygwin not supported". Please help me out
Thanks in advance.
Node in my experience runs fine in cygwin, what Node usually has EINVAL errors in seems to be MINTTY which is a terminal emulation 'skin' that is default to cygwin. I still am not sure why these EINVAL errors happen 100% but the following are the steps and tricks I use to get node working.
In my /cygwin/home/{username}/.bashrc I add node to path so cygwin can find it
export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"
If you run a 32 bit version of node:
export PATH=$PATH:"/cygdrive/c/Program Files (x86)/nodejs/"
Then to make npm run without windows to linux issues I launch cygwin in admin mode then run:
dos2unix '/cygdrive/c/Program Files/nodejs/npm'
At this point running files and most npm packages will run in MINTTY just fine, although every once and awhile you will run into EINVAL issues with certain npm packages as karma. Also you will not be able to run the interpreter directly in MINTTY, anytime I want to do these things I run:
cygstart /bin/bash
This will open a native cygwin bash.exe window, from here you run the interpreter or an any troubling package command that results in a EINVAL. It slightly sucks you have to do this but I rarely use this day to day, and I love MINTTY too much to not use it.
Also note that you can run any one line node code in MINTTY by just running something like:
node -e "console.log('hello node')"
As a simpler derivative of troy's answer for those just looking to install NPM packages:
Install Node.js with the Windows installer package.
Add it to the PATH with export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/" (obviously replacing the path to Node.js's installation directory with where you installed it).
There's a current bug in the Windows version that can be fixed by running mkdir -p ~/AppData/Roaming/npm. This is a bug for all of Windows and not just Cygwin. At some point of the future, you won't have to do this anymore, but the command shouldn't have any negative side effects.
Test it. Eg, npm install pretty-diff -g.
In order to be able to run the newly installed software, you'll need to add the install locations to your PATH. You can find these with npm bin -g and npm bin (the -g flag is the "global" installation location).
Not really anything special that you have to do to get it to run in Cygwin (although I can't say if everything works).
Use Console2, it allows you to run create tabs of CLI shells. It seems running cygwin inside console2 allows me to use node REPL just fine. I have no idea why :P
Follow this guide to add cygwin to console2:
http://blog.msbbc.co.uk/2009/11/configuring-console-2-and-bash-with.html
With Bjørn's suggestion (using Console2) and Soyuka's alias (steps here), my node.js v0.10.13 and npm v1.3.2 are now working under Babun v1.02, a Cygwin distribution.
For windows, Just run bash.exe in cmd, so that you could have a bash work around with cmd console directly, which could support ALL NODE WORKING PERFECTLY.
C:\Users\郷>bash
郷#CHIGIX ~
$ node
>
I'm using this wrapper in /usr/local/bin/node (note no extension!)
#!/bin/sh
_cmd="$(cygpath -lw -- "$1" )"
shift
"/proc/cygdrive/C/Program Files/nodejs/node.exe" "$_cmd" "$#"
This is far from perfect, as Node do not understand Cygwin directory tree, but works relatively well with relative names.
From Windows, run Cygwin.bat (instead of Cygwin Terminal) then in that run node: see and reply on this answer on this effectively-same question asked 1.5 years later.
Grab and run the node.js Windows installer.
In the Cygwin prompt type node
See if it works.

Resources