Could not start Tern server in Emacs - node.js

I have the latest version of Emacs and Tern but I have a problem with using the plugin. When I use any Tern-related commands I get this command from editor:
Wrong type argument: listp, "Could not start Tern server
env: node: No such file or directory.
"
As far as I know, Tern uses NodeJs to do it's job, I have the latest version of NodeJs also but I don't know why I get this error.

Add the following line to your init file, replacing the path for node if necessary depending on where node is installed:
(setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))

I used to have the same problem and just make it work. The thing is that the plugin have hard coded tern-command path. So I modify the path to "/usr/local/bin/tern".
And because I install the plugin with emacs 24's package, I have to delete tern.elc in the plugin folder and recompile it by C-u 0 M-x byte-recompile-directory.

Related

Setting custom node version (path) for Neovim

TL;DR: I'd like to use node v14 for neovim only, and v8 for everything else. Suggestions?
Hello!
I have recently started using neovim for development purposes. I have installed several plugins, some of which require higher node versions than 8 - which is mandatory for my work environment. I used nvm, downloaded latest v14. Since nvm takes a ton of time to load up, I have added path in zshrc, which I simply changed from export PATH=../v8../bin to export PATH=../v14../bin. So far, so good. But my work repos throw errors, since they require node v8.
Now, I start up nvim on v14 in a session, then manually change path in zhsrc for work sessions to v8. This seems cumbersome to do every time. Is there a better way?
Use nvim environment variable: let g:node_host_prog = '/usr/local/bin/neovim-node-host'
See Neovim Provider Documentation
The following line can be added to your nvim/init.vim to prepend a directory DIR to your PATH when nvim is launched.
let $PATH = 'DIR:' . $PATH
Here's an example with the directory you specified.
let $PATH = '../v14../bin:' . $PATH

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.

Can't evaluate Clojure web project code using Vim and tpope's Fireplace plugin?

I've installed the Leiningen Clojure project tool using: brew install leiningen (the REPL works fine).
I wanted to use Vim to write some Clojure code and so I've installed the following plugins:
https://github.com/tpope/vim-fireplace/
https://github.com/tpope/vim-classpath
https://github.com/tpope/vim-clojure-static/
https://github.com/vim-scripts/paredit.vim
https://github.com/kien/rainbow_parentheses.vim
I opened three terminal consoles and execute commands in this order:
lein new compojure my-project
lein repl
cd my-project && vim
Within Vim I first connect to the REPL...
:Connect nrepl://127.0.0.1:60356
...then I open the my-project/src/my_project/handler.clj file and press cpp (which I think is aliased to :Eval whilst my cursor is on the first character of the first opening parenthesis.
At this point I get the following error:
FileNotFoundException Could not locate my_project/handler__init.class or my_project/handler.clj on classpath: clojure.lang.RT.load (RT.java:443)
I've not been able to find any appropriate solutions?
In order for lein to properly set up your classpath, it must be started inside the project directory. Change directory into the my-project directory before starting lein repl.

Sails.js - PATH variable - sails command not recognized

After I npm installed Sails.js on Windows Server 2008, "sails" command is not recognized.
Can someone give me a hint on what values to use in the PATH variable? As I understand it is Node.exe that runs the sails.js file. But if I try tunning "node sails.js" command in cmd, it recognizes it, but can't find some of the dependencies.
On my Windows 7 machine everything installed and is running like a charm.
I ended up writing a batch file and putting it into system32 folder "c:\Windows\System32\sails.bat" with this one line:
node C:\Users\XXXXXXXX\AppData\Roaming\npm\node_modules\sails\bin\sails.js
Now, sails lift works well.
Did you try using the -g (for global) option?
If I use:
npm install -g sails
On either Windows 8.1 or Server 2012R2, I find it is accessible from the path just fine.
Install sails globally
npm install -g sails
If you have right to add Environment variables (Start => Computer=> Properties=>Advance system setting => Advance(Tab)=>Environment Variable(button at the bottom) => User variable for ...(the top one) => find "PATH" => edit ) and add the location of your npm folder (C:\Users\XXXXXX\AppData\Roaming\npm) (this folder can be hidden so enable show hidden folder to locate your path)
open new cmd window and enjoy sails :)
it looks line a sails.cmd file is create in the global npm folder, so if you add this folder C:\Users\XXXXXX\AppData\Roaming\npm to your PATH sails will be a recognized command, and will accept all valid parameters (tried new and lift and both look OK).
In this way all other node packaged that are command line based should work, if they follow this convention to install on Windows (I think this is the case).
I don't have a Windows Server 2008 to test on but it seems it fails to do this process automatically, as it does on Windows 7
If you add a .bat file in system32, remember to add parameters to the bat script. Found that out after trying some of the solutions previously posted here. My example:
C:\Users\Anton\AppData\Roaming\npm\sails %1 %2
Sails is not a directory there, it's a file. Hope this helps someone.
For ubuntu 16.+
Get prefix of node
npm get prefix
look loke this : '/home/ubuntu/node'
now open bash_profile
sudo vim ~/.profile
Add this line if you already have path in this file
export PATH="$PATH:/home/ubuntu/node/bin"
if you node prefix is diff replace with your prefix
export PATH="$PATH:{ your-node-prefix }/bin"
you can add new 'node' commands like 'npm', using batch scripting.
Create a sails.cmd file in your desktop. (new text file -> rename to
'sails.cmd').
Right-click on sails.cmd and select Edit.
Copy and paste this code into your sails.cmd:
#ECHO OFF
SET arguments=%1 %2 %3 %4 %5 %6 %7 %8 %9
node %APPDATA%\npm\node_modules\sails\bin\sails.js %arguments%
Save and copy your sails.cmd into your Node.js installation
directory, for example: C:\Program Files\nodejs
And now everything with sails.js on windows are very simple. Just run this command in your terminal:
sails or sails -v or whatever you want with sails! ;)
Enjoy!
UPDATE!
At this time I highly recommend using the WizofOz solution. It is the most correct way to proceed in a node.js environment.
To help clarify for Windows 8 users. After installing sails globally if receiving errors do this:
Create a sails.txt file
Add this
node C:\Users\XXXXXXX\npm\node_modules\sails\bin\sails.js new
node C:\Users\XXXXXXX\npm\node_modules\sails\bin\sails.js lift
Now re-save it as sails.bat
Add this new file to your C:\Windows\System32
Navigate to the folder you want to hold your new sails app. Scaffold the app with the following command:
sails new
If you don't want a front-end, instead type:
sails new --no-frontend
We can also launch the app using the lift command:
sails lift
This will launch our new app on port 1337
For MAC Users, try this (run the following on your terminal)
export PATH="/Users/username/.npm-packages/bin:$PATH"

Node.JS - How to Run Node Command from any path?

I have installed the latest node.js from here . I see the %Path% variables have been set for Node.js. But, When i run node from C:\ , i get a "Node is not an recognized comman". But node command is working fine from "C:\Program Files (x86)\nodejs" path. Can i not run Node commands from C:\ or Say from an other path if i set the Env variables right? Please help. I am running a Win7 X64.
Thank You,
Faraaz
I had the exact same problem, but in my PATH variable I had: C:\Program Files\nodejs\.
After changing it to C:\Program Files\nodejs I could access it from anywhere.
What happens if you run node --version? I have never tried node.js from windows but if that doesn't work there is something wrong with your paths.
What do you get when you run echo %PATH%?
You should check if the path C:\Program Files (x86)\nodejs is present in your %PATH. If not, add it via the system properties (persistent change). In any case, restart your command prompt, it'll reload the %PATH variable. If you're lucky, it should work now :)
Most likely it happens because there is no Node path in your PATH environment variable.
I see two ways to solve this
Just add Node path into the end of PATH.
Reinstall Node as administrator
run 7-zip (or some file manager) with administrator privileges >>
browse to node-installer.msi >> open it, install node >> enjoy
My Sublime was working with Nodejs fine. I could press Alt-R and see the output from Node in Sublime. Then at some point I upgraded Sublime. I now have version 2.02 build 2221
And at some later point I tried Alt-R and got this infamous message
'node' is not recognized as an internal or external command
But it had worked, so what changed?
The steps I took to fix it were to install git bash and then
$ git clone https://github.com/tanepiper/SublimeText-Nodejs.git
$ cd SublimeText-Nodejs/
$ git checkout 095ba03344
Back in Sublime I clicked Preferences > Browse Packages. This opened up Windows Explorer with the folder:
C:\Users\me\AppData\Roaming\Sublime Text 2\Packages
I replaced the contents of the Nodejs folder with the git version. Re-started Sublime and then Alt-R sprang back into life.
Other things that turned out to be irrelevant were changing the file Nodejs.sublime-settings and tampering with system environment variables. The only thing that worked was 095ba03344 as described here
https://github.com/tanepiper/SublimeText-Nodejs/pull/39

Resources