eslint / eslint-transforms

Codemods for the ESLint ecosystem
Other
22 stars 8 forks source link

Problems running (in windows?) #2

Closed lukeapage closed 8 years ago

lukeapage commented 8 years ago

First problem was after I installed globally..

$ eslint-transforms new-rule-format src/rules/in-params.js
c:\Program Files (x86)\nodejs\node_modules\eslint-transforms\node_modules\shelljs-nodecli\lib\shelljs-nodecli.js:104
            throw new Error("Couldn't find " + name + ".");
            ^

Error: Couldn't find jscodeshift.
    at Object.module.exports.exec (c:\Program Files (x86)\nodejs\node_modules\eslint-transforms\node_modules\shelljs-nodecli\lib\shelljs-nodecli.js:104:19)
    at Object.<anonymous> (c:\Program Files (x86)\nodejs\node_modules\eslint-transforms\bin\eslint-transforms.js:11:9)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:138:18)
    at node.js:974:3

I found this very strange since js-codeshift should have been findable. Possibly npm corrupted the install or something?

So I decided to installl locally and run there, which worked better, but I couldn't get it to run...

Luke@LUKE-VAIO /c/git/eslint-plugin-destructuring (master)
$ ./node_modules/.bin/eslint-transforms  new-rule-format src/rules/in-params.js
ERROR Transform file c:\git\eslint-plugin-destructuring\lib\new-rule-format\new-rule-format.js does not exist

Luke@LUKE-VAIO /c/git/eslint-plugin-destructuring (master)
$ ./node_modules/.bin/eslint-transforms  node_modules/eslint-transforms/lib/new-rule-format src/rules/in-params.js
ERROR Transform file c:\git\eslint-plugin-destructuring\lib\node_modules\eslint-transforms\lib\new-rule-format\node_modules\eslint-transforms\lib\new-rule-format.js does not exist

Luke@LUKE-VAIO /c/git/eslint-plugin-destructuring (master)
$ ./node_modules/.bin/eslint-transforms  node_modules/eslint-transforms/lib/new-rule-format src/rules in-params.js
ERROR Transform file c:\git\eslint-plugin-destructuring\lib\node_modules\eslint-transforms\lib\new-rule-format\node_modules\eslint-transforms\lib\new-rule-format.js does not exist

Luke@LUKE-VAIO /c/git/eslint-plugin-destructuring (master)
$ ./node_modules/.bin/eslint-transforms  ../node_modules/eslint-transforms/lib/new-rule-format src/rules in-params.js
ERROR Transform file c:\git\eslint-plugin-destructuring\node_modules\eslint-transforms\lib\node_modules\eslint-transforms\lib\new-rule-format.js does not exist

Luke@LUKE-VAIO /c/git/eslint-plugin-destructuring (master)
$ ./node_modules/.bin/eslint-transforms  ../node_modules/eslint-transforms/lib/new-rule-format/new-rule-format src/rules/in-params.js
ERROR Transform file c:\git\eslint-plugin-destructuring\node_modules\eslint-transforms\lib\new-rule-format\node_modules\eslint-transforms\lib\new-rule-format\new-rule-format.js does not exist

Luke@LUKE-VAIO /c/git/eslint-plugin-destructuring (master)
$ ./node_modules/.bin/eslint-transforms  ../new-rule-format src/rules/in-params.js
ERROR Transform file c:\git\eslint-plugin-destructuring\new-rule-format.js does not exist

I couldn't get it to load the rule.

I noticed when running eslint-transforms by itself it still reports itself as jscodeshift, so I tried this instead...

$ ./node_modules/.bin/jscodeshift src/rules/in-params.js -t node_modules/eslint-transforms/lib/new-rule-format/new-rule-format.js

and that works fine. I'm running in git bash on windows.

lukeapage commented 8 years ago

the first issue with the global install not finding jscodeshift might relate to : https://github.com/nzakas/shelljs-nodecli/issues/2

The 2nd is probably due to the fact I'm running this from .bin while in a different directory and the relative path to the transform isn't working.

vitorbal commented 8 years ago

@lukeapage thank you for the bug report! The 2nd issue is due to the fact that the executable was not using __dirname to resolve the location of the transforms.. apologies for that. #3 should make sure this doesn't happen anymore.

For the first issue described I'm afraid I need some help figuring out if it indeed relates to nzakas/shelljs-nodecli#2. @platinumazure sorry to bug you, but since you reported that issue originally, do you happen to know if this is true?

edit: nevermind, seems I figured out a solution for this thanks to @nzakas. Will try to submit a fix today!

lencioni commented 7 years ago

I've run into a similar issue just now on OS X in zsh. Node 6.2.2, npm 3.9.5, nvm 0.30.1. I just tried updating nvm to 0.31.3, and same problem.

I installed by running npm install -g eslint-transforms. This seemed to include jscodeshift:

└─┬ eslint-transforms@0.0.1
  ├─┬ jscodeshift@0.3.26

When I run eslint-transforms, I get the same error:

/path/to/.nvm/versions/node/v6.2.2/lib/node_modules/eslint-transforms/node_modules/shelljs-nodecli/lib/shelljs-nodecli.js:104
            throw new Error("Couldn't find " + name + ".");
            ^

Error: Couldn't find jscodeshift.
    at Object.module.exports.exec (/path/to/.nvm/versions/node/v6.2.2/lib/node_modules/eslint-transforms/node_modules/shelljs-nodecli/lib/shelljs-nodecli.js:104:19)
    at Object.<anonymous> (/path/to/.nvm/versions/node/v6.2.2/lib/node_modules/eslint-transforms/bin/eslint-transforms.js:11:9)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (node.js:348:7)
    at startup (node.js:140:9)

It looks like it brought in shelljs-nodecli@0.1.1, if that helps debug anything. Perhaps this is an issue when using node only via nvm?

nzakas commented 7 years ago

The fix hadn't been released even though it was merged. I just did a release so if you update the package it should work.

lencioni commented 7 years ago

Much better. Thanks!