This is the error I get in the output pane of Vscode. There is no log in the developer tools console.
[Info - 9:16:38 PM] ESLint server is running.
(node:11580) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token .
I can lint the file fine if I start eslint in the console (Bash for Windows).
I do use Vscode in Windows 10, and eslint (and nodejs) is installed inside Bash for Windows (Linux subsystem). My Windows build is 15063.296. Node.js version is v8.1.0, eslint is v3.19.0.
So I start the Windows version of Vscode but I point to eslint inside Linux with "eslint.nodePath".
This will not work right now. ESLint is run in its own process and kept alive to lint while you type. Otherwise we would need to start eslint command line version while you type. The process we start to run eslint in is not running in the Linux subsystem hence it doesn't see the same environment.
Thank you for the explanation, I understand that it might not be solvable, as not supported by WSL. It is not that much of an issue.
Newbie here
There's any workaround to use the eslint installed in WSL?
See my comments here: https://github.com/Microsoft/vscode-eslint/issues/397
As commented there work has to happen in VS Code first to make this a nice experience since when running in WSL paths need to be different as well and VS Code on Windows assumes a Windows path format. I will keep this issue for tracking this open.
I got it working with "eslint.nodePath": "C:/Users/WINDOWSUSERNAME/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/home/UBUNTUUSERNAME/.npm-global/lib/node_modules",
I have nodejs and eslint installed inside WSL with VSCode installed on Windows. Just point eslint.nodePath to your global node_modules folder and it should work.
@varghesejacob as noted in the WSL documentation (from Windows, not related to VS Code at all) direct access to the Linux file system from withing Windows (e.g C:/Users/WINDOWSUSERNAME/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/home/UBUNTUUSERNAME/.npm-global/lib/node_modules) is highly discouraged. So I would not go down that path.
Why is this discouraged as this would not be writing to the Linux file system? I thought the purpose of WSL was to be able to run linux tools in Windows. Maybe I am missing the point
@jrock2004 this is something the WSL documentation states and is independent of VS Code.
Found a more reliable way to use WSL-installed node & eslint, using the wsl wrapper command that is part of WSL.
node.bat:
@echo off
wsl node %*
node replaced by eslint (Can repeat this for whatever other commands you need to be made available).eslint.nodePath to C:\\path\\to\\batch\\file\\node.bat (note the double backslashes)Oh and this is quite useful too:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\wsl.exe",
anyone got this to work. Been trying stuff for hours :(
This will improve in VS Code itself. See https://github.com/Microsoft/vscode/wiki/Roadmap WSL support.
Found a more reliable way to use WSL-installed node & eslint, using the
wslwrapper command that is part of WSL.
- Create a batch file with the following content and save it as
node.bat:
@echo off wsl node %*- Make another with
nodereplaced byeslint(Can repeat this for whatever other commands you need to be made available).- Set
eslint.nodePathtoC:\\path\\to\\batch\\file\\node.bat(note the double backslashes)- Restart Code if needed.
Found a more reliable way to use WSL-installed node & eslint, using the
wslwrapper command that is part of WSL.
- Create a batch file with the following content and save it as
node.bat:
@echo off wsl node %*- Make another with
nodereplaced byeslint(Can repeat this for whatever other commands you need to be made available).- Set
eslint.nodePathtoC:\\path\\to\\batch\\file\\node.bat(note the double backslashes)- Restart Code if needed.
Don't suppose you can explain this a bit more as I can't seem to get it working
Don't suppose you can explain this a bit more as I can't seem to get it working
To start with, the instructions are for VS Code installed in Windows, with node and eslint binaries available in the bash %PATH. You may also need the Windows version of node installed, but this can also cause other issues, so try without it first.
The wsl command available once WSL is enabled is a wrapper that accepts a linux command (and optionally its arguments) as input, and runs the given linux command with its arguments from within a bash environment. For example, wsl ls /home/user1 from the windows command prompt will work identical to ls /home/user1 from the WSL bash terminal. In other words, prepending wsl in Windows to any linux command you would issue makes it run as if it was run from within the linux bash prompt. The batch file is a shortcut which automatically prepends wsl to the commands we want to run this way.
@echo off in step 1 in my earlier comment is just to turn off printing the given command back into the output, and wsl node %* runs the linux node binary (which should be present in %PATH in bash as mentioned earlier) with the arguments given to the node.bat batch file.
Running node ls from the Windows command prompt runs node.bat ls, which results in running wsl node ls from the batch file, which then runs node ls from within the bash environment. Once the node.bat file is set as the command to run for eslint (step 3), eslint will use the batch file to issue node commands.
Step 2 is to do the same for the eslint binary within the linux env, so that Code can simply invoke eslint to run eslint from within the bash env.
The double backslashes are required for all paths in Code.
Hope this helps
1.33 may have just fixed this: https://code.visualstudio.com/docs/remote/wsl
I seen this. I'm yet to test but looks great. Can't wait to try it
On Sat, 4 May 2019, 00:25 Hikurangi, notifications@github.com wrote:
1.33 may have just fixed this:
https://code.visualstudio.com/docs/remote/wsl—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode-eslint/issues/251#issuecomment-489269515,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACNEK5C7GBBBYYORE7IVT5LPTTCXTANCNFSM4DOW63MQ
.
Yes, https://code.visualstudio.com/docs/remote/wsl will fix this.
Will close the issue since there is nothing to do in the ESLint extension :-)
Most helpful comment
Found a more reliable way to use WSL-installed node & eslint, using the
wslwrapper command that is part of WSL.node.bat:@echo off wsl node %*nodereplaced byeslint(Can repeat this for whatever other commands you need to be made available).eslint.nodePathtoC:\\path\\to\\batch\\file\\node.bat(note the double backslashes)