rizowski / eslint-watch

ESLint with simple watching capabilities
https://www.npmjs.com/package/eslint-watch
MIT License
196 stars 29 forks source link

Fails to run on Windows when eslint is installed globally. #114

Closed lucasfolino closed 7 years ago

lucasfolino commented 7 years ago

Environment

Basic Description of the problem

When running esw I get that eslint-watch cannot find eslint. The command esw will not run at all even with -h, --esw-version.

How to reproduce it

  1. Command: esw ...
  2. ...

Debug output:

// to grab debug output set DEBUG=esw:*

      throw new Error('Eslint needs to be installed globally or locally in node_modules.');
            ^
Error: Eslint needs to be installed globally or locally in node_modules.
    at loadEslintPath (C:\Users\<username>\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:24:13)
    at Object.<anonymous> (C:\Users\<username>\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:10:
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\<username>\AppData\Roaming\npm\node_modules\eslint-watch\src\index.js:4:1)
rizowski commented 7 years ago

@lucasfolino Thanks for reporting this. I need the debug output to understand more of the problem. Can you re-run the command with the environment variable DEBUG set to esw:* and paste the output?

lucasfolino commented 7 years ago

Here is the output of DEBUG turned on. It seems to be a path issues. I have tried removing and re-adding eslint. Not sure if it would be possible or difficult to add an eslint path config in either the cli switch or config file.

esw : Mon, 15 May 2017 12:39:39 GMT esw:internal-settings Error: ENOENT: no such file or directory, access 
'C:\Users\<username>\node_modules\.bin\eslint.cmd'
At line:1 char:1
+ esw 2> c:\temp\esw.err
+ ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Mon, 15 May 201...bin\eslint.cmd':String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

    at Error (native)
    at Object.fs.accessSync (fs.js:249:11)
    at loadEslintPath (C:\Users\<username>\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:15:8)
    at Object.<anonymous> (C:\Users\<username>\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:10:20)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)

C:\Users\<username>\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:24
      throw new Error('Eslint needs to be installed globally or locally in node_modules.');
            ^

Error: Eslint needs to be installed globally or locally in node_modules.
    at loadEslintPath (C:\Users\<username>\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:24:13)
    at Object.<anonymous> (C:\Users\<username>\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:10:20)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\<username>\AppData\Roaming\npm\node_modules\eslint-watch\src\index.js:4:1)
rizowski commented 7 years ago

@lucasfolino Can you give me the npm version you have too?

lucasfolino commented 7 years ago

Node: 6.10.3 NPM: 3.10.10

Yeah everything is the latest. This is a new setup.

rizowski commented 7 years ago

Hmm I re-ran a build to see if it was something new my tests could have caught. But they all passed. https://ci.appveyor.com/project/rizowski/eslint-watch/build/107 Let me try installing this on my windows box and I will get back to you.

rizowski commented 7 years ago

@lucasfolino Do you have both eslint and eslint-watch installed globally? Or is one global and the other local? Or both local? How do you have them set up?

lucasfolino commented 7 years ago

I installed them both globally.

rizowski commented 7 years ago

I'm not able to reproduce this on my machine. Can you look at C:\Users\%USERNAME%\AppData\Roaming\npm and see if there is an eslint.cmd file?

lucasfolino commented 7 years ago

Yes there is. I have no issues running eslint. Any way I can manually change the path in a config file somewhere?

lucasfolino commented 7 years ago

I am noticing the path: ENOENT: no such file or directory, access 'C:\Users\%USERNAME%\node_modules.bin\eslint.cmd' Is incorrect. Shouldn't it be pointing to the :\Users\%USERNAME%\AppData\Roaming\npm folder?

rizowski commented 7 years ago

There isn't. Yes, it should be. It's strange that it is looking there. I have two separate Windows machines that run it just fine. This is the logic for finding eslint's path https://github.com/rizowski/eslint-watch/blob/master/src/settings.js#L14

rizowski commented 7 years ago

Are you running this through Powershell?

lucasfolino commented 7 years ago

Yes. I also tried it on normal cmd.exe cause I know that PS can cause issues with node sometimes. I just tried removing and adding through cmd.exe as well incase some environment variable causes issues. Still same issue.

rizowski commented 7 years ago

@lucasfolino Have you found anything new about this issue?

lucasfolino commented 7 years ago

No I have not. I want to try this on a different machine, and in the WSL Ubuntu environment. If it works there I would consider that a usable workaround.

lucasfolino commented 7 years ago

I am closing this since it seems to only happen on one machine.

zlzdp commented 7 years ago

the same issue happend with me.

  throw new Error('Eslint needs to be installed globally or locally in node_

modules.'); ^ Error: Eslint needs to be installed globally or locally in node_modules. at loadEslintPath (C:\Users\user\AppData\Roaming\npm\node_modules\eslint-w atch\src\settings.js:24:13)

I found C:\Users\user\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js is not exist.

you not publish the setting file to npmjs.com .npmignore

src

Environment: node v8.1.3 npm 5.0.3 eslint 4.1.1 (in global) eslint-watch@3.1.2 (in global)

zlzdp commented 7 years ago

/src/setting.js maybe a better way to get eslintPath: excute command:

npm root -g
pklaes commented 6 years ago

Same problem here. Seems like it is looking in local, not in global. File eslint.cmd actually is in C:\Users\pk\AppData\Roaming\npm

Environment: node v8.11.2 npm 5.6.0 eslint 5.4.0 (in global) eslint-watch@4.0.2 (in global)

Debug-Output (in Powershell, same in cmd) PS D:\tfs\IMSware\Mobile\IMS.IMSWARE.HelpDesk\APP.HelpDesk> $env:DEBUG="esw:*" PS D:\tfs\IMSware\Mobile\IMS.IMSWARE.HelpDesk\APP.HelpDesk> esw -v esw:internal-settings Error: ENOENT: no such file or directory, access 'D:\tfs\IMSware\Mobile\IMS.IMSWARE.HelpDesk\APP.HelpDesk\node_modules.bin\eslint.cmd' esw:internal-settings at Object.fs.accessSync (fs.js:301:11) esw:internal-settings at accessSync (C:\Users\pk\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:16:8) esw:internal-settings at Object. (C:\Users\pk\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:11:20) esw:internal-settings at Module._compile (module.js:652:30) esw:internal-settings at Object.Module._extensions..js (module.js:663:10) esw:internal-settings at Module.load (module.js:565:32) esw:internal-settings at tryModuleLoad (module.js:505:12) esw:internal-settings at Function.Module._load (module.js:497:3) esw:internal-settings at Module.require (module.js:596:17) esw:internal-settings at require (internal/module.js:11:18) +0ms

C:\Users\pk\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:25 throw new Error('Eslint needs to be installed globally or locally in node_modules.'); ^ Error: Eslint needs to be installed globally or locally in node_modules: node_modules.bin\eslint.cmd at loadEslintPath (C:\Users\pk\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:25:13) at Object. (C:\Users\pk\AppData\Roaming\npm\node_modules\eslint-watch\src\settings.js:11:20) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (C:\Users\pk\AppData\Roaming\npm\node_modules\eslint-watch\src\index.js:4:1)