Babel-eslint: TypeError: Cannot read property 'visitClass' of undefined

Created on 1 Feb 2016  ยท  65Comments  ยท  Source: babel/babel-eslint

hzoo here just adding: this is fixed the latest 2 versions (update your babel-eslint).

npm i babel-eslint will be >= 4.1.7.

Use npm install --save-dev babel-eslint@next or npm i [email protected]

escope updated to babel 6

Eslint version: 1.4.1, 1.10.3
babel-eslint: 4.1.4

The error:

TypeError: Cannot read property 'visitClass' of undefined
    at monkeypatch (/usr/local/lib/node_modules/babel-eslint/index.js:201:40)
    at Object.exports.parse (/usr/local/lib/node_modules/babel-eslint/index.js:374:5)
    at parse (/usr/local/lib/node_modules/eslint/lib/eslint.js:539:27)
    at EventEmitter.module.exports.api.verify (/usr/local/lib/node_modules/eslint/lib/eslint.js:663:19)
    at processText (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:220:27)
    at processFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:257:18)
    at executeOnFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:600:23)
    at /usr/local/lib/node_modules/eslint/lib/cli-engine.js:624:17
    at Array.forEach (native)
    at CLIEngine.executeOnFiles (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:622:18)

No matter what path i give eslint (eslint *.js, eslint androgenix/assets/js/**/*.js) i get this error. Not sure where to start looking to fix this. Our old projects seem to work okay but we just started this one and are receiving this error.

Most helpful comment

npm install --save-dev [email protected] fixes issue

All 65 comments

same issue.

This appears to be an incompatibility with the recently released escope 3.4.0. Downgrading to 3.3.0 resolved this issue for me.

we are also seeing this as of a couple hours ago, with cli eslint jsdir -f html -o eslint/eslint.html

@chromakode How do you go about downgrading a packages escope package?

npm install --save-dev [email protected] fixes issue

@Havunen I'm still getting the same issue when trying that, tried installing locally and globally (I run eslint off of -g)

but thats definitely a work around as my project has no direct dependency to escope

@dan-gamble strange, I just did what @chromakode suggested and it worked for me.

@dan-gamble You may still have a copy of escope 3.4.0 under node_modules/eslint/node_modules/escope that is being used. Check npm ls | grep escope to list your installed versions, and rm -r any if necessary.

+1

+1

+1 to @Havunen

Edit, actually that didn't help after I cleared node_modules and ran again. I've had to disable eslint in my project as a result.

+1

+1

+1

+1

Guys you can use my fork of @christophehurpeau's fix to install babel-eslint for now (if you're in need of a urgent fix just like me)

npm install git://github.com/lprajus2007/babel-eslint

@lprajus2007 tip: npm install lprajus2007/babel-eslint

Thanks for the fork @lprajus2007 ! I'm going to use that for now.

Thanks @lprajus2007 doing the same until this issue is fixed.

@lprajus2007 works for me, thanks.

I can push on a fix soon (https://github.com/babel/babel-eslint/pull/244). Sounds like I need to do it for 4.x and 5.x beta?

@hzoo yes, this is broken for both

Sounds like I need to do it for 4.x and 5.x beta?

Yup. And thanks for the quick fix!

Published [email protected]

I will move [email protected] to the next tag for npm. and make a new version for babel-eslint 4.

Downgrading to escope 3.3.0 worked for me. Thx

Thanks @hzoo can you put an update here when you release 4.1.7?

Ok both are published - let me know if it's good.

npm view babel-eslint dist-tags

{ latest: '4.1.7', next: '5.0.0-beta9' }

:+1: 4.1.7 fixed the issue for me

:+1: Same here. Thanks.

4.1.7 fix worked for me, thanks!

Same here, 4.1.7 fixed the problem :+1:

5.0.0-beta9 is not available via NPM

@fkrauthan I moved it to be on the next tag.

npm i babel-eslint will be 4.1.7.
Use npm install --save-dev babel-eslint@next or npm i [email protected]

Yeah but I get the following error message:

npm ERR! No compatible version found: [email protected]
npm ERR! Valid install targets:
npm ERR! 5.0.0-beta8, 5.0.0-beta7, 5.0.0-beta6, 5.0.0-beta5, 5.0.0-beta4, 5.0.0-beta3, 5.0.0-beta2, 5.0.0-beta1, 4.1.6, 4.1.5, 4.1.4, 4.1.3, 4.1.2, 4.1.1, 4.1.0, 4.0.10, 4.0.9, 4.0.8, 4.0.7, 4.0.6, 4.0.5, 4.0.4, 4.0.3, 4.0.2, 4.0.1, 4.0.0, 3.1.30, 3.1.29, 3.1.28, 3.1.27, 3.1.26, 3.1.25, 3.1.24, 3.1.23, 3.1.22, 3.1.21, 3.1.20, 3.1.19, 3.1.18, 3.1.17, 3.1.16, 3.1.15, 3.1.14, 3.1.13, 3.1.12, 3.1.11, 3.1.10, 3.1.9, 3.1.8, 3.1.7, 3.1.6, 3.1.5, 3.1.4, 3.1.3, 3.1.1, 3.1.0, 3.0.1, 3.0.0, 2.0.2, 2.0.0, 1.0.14, 1.0.13, 1.0.12, 1.0.11, 1.0.10, 1.0.9, 1.0.8, 1.0.7, 1.0.6, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0.0

4.1.7 works for me too. Thanks for the quick fix! :+1:

@fkrauthan that is really weird. [email protected] is definitely showing up for me and is there when I do npm view babel-eslint. If I do npm i [email protected] (not created), I can see beta9 in the valid install targets

Hmm maybe a caching issue and it needs a bit more time until it shows up for me?

@fkrauthan i was able to install beta9. i usually use the min-cache=1000000 trick for speeding up installs, but in this case i had to install without it or it did not find it.

@bdefore My bad. Our artifcatory server was caching npm requests. Just cleared the artifactory cache and it was able to pull beta9

The solution given above npm install --save-dev [email protected] also worked for me.

However, on my teammate's setup, it didn't work until I found grunt-eslint also had escope. Told him to uninstall grunt-eslint and reinstall. When I did a cat package.json again on his grunt-eslint, escope is gone. Our app finally worked on his machine.

What is the final solution? Definitely we don't want to go inside each node_modules and installing this kind of fix.

@c0debreaker did you see my post above? https://github.com/babel/babel-eslint/issues/243#issuecomment-178203256

I pushed a new release of babel-eslint on both 4.x and 5.x so just update that and you should be good.

@hzoo Did you republish beta9? Because we have the same problem with our artifactory - cached beta9 but it's broken!
Maybe you can update to beta10? We can't use eslint because of that whole day

@klimashkin Just log into the webinterface of your artifcatory, remove the broken package/invalidate the cache and you should be fine

@fkrauthan I got it, but it's a really bad practice and it should be done by many many consumers

@klimashkin I never got a bad package. My problem was just that artifcatory wasn't contacting npm because of the internal cache timeout. Not much @hzoo can do against that.

@hzoo can raise version

he did with beta9 which is fine and which was raised from original beta8.

Thanks a lot @hzoo :)

4.1.7 also worked for me. I installed @next but saw beta so I uninstalled it again. Thanks a lot

4.1.7 works for me. Thanks! :+1:

:+1: for 4.1.7

Works on 4.1.8

Using babel-eslint 4.1.7 or 4.1.8 does not work for me. But downgrading escope to 3.3.0 works. I am confused eslint 4.1.7 / 4.1.8 worked for others!

@sbhaktha Try to remove node_modules and do npm install again. If doesn't work, check if your company have npm proxy with cache

Did you install it globally ? Try removing it everything about it (local and global and then do an install)

I realized I was depending on another package that take dependency on babel-eslint as well, so the version had to be updated there as well. Working on it! Thanks @klimashkin and @balaurzor.

@developit thx! see you again!

Same issue here with eslint 2.1.0 and babel-eslint 5.0.0.
I also try babel-eslint 4.1.8, but it do not work.

4.1.7 works for me. Thanks! :+1:

โ”œโ”€โ”ฌ [email protected]
โ”‚ โ””โ”€โ”€ [email protected]
โ””โ”€โ”€ [email protected]

Still have this issue:

TypeError: Cannot read property 'visitClass' of undefined
    at monkeypatch (/Users/username/Repos/Application/node_modules/babel-eslint/index.js:201:40)

Can I at least set it to warn?

maybe you want to update your eslint seing that you are using 5.0 beta9 and the stable version is out

Using npm install [email protected] babel-eslint@next(to get the latest versions) I get the exact same error.

โ”œโ”€โ”€ [email protected]
โ””โ”€โ”€ [email protected]
TypeError: Cannot read property 'visitClass' of undefined
    at monkeypatch (/Users/rtanasescu/Repos/arilove-fe/node_modules/babel-eslint/index.js:201:40)

I've even tried to use $ npm install [email protected] babel-eslint --save-dev, same thing.

I'm working on a react app, with "babel": "5.8.23".

Is there an option in the configuration file that I could disable? (I don't mind a bit of missing functionality, it's better than no functionality)

@radu-arimatrix You need to be on babel-eslint@^6.0.0 for support of eslint@^2.3.0. (Technically for eslint@^2.0.0, but it "sortof" worked in versions before v2.3.0)

โ”œโ”€โ”€ [email protected]
โ””โ”€โ”€ [email protected]
TypeError: Cannot read property 'visitClass' of undefined
    at monkeypatch (/Users/rtanasescu/Repos/arilove-fe/node_modules/babel-eslint/index.js:201:40)

No, still the same error. Thank you to who has invited me to the slack group for the React Program, I'll try to get help there :)

I'm trying to do this with Sublime, would Atom work better?

@dan-gamble - Late to the game but I noticed your question on how to change a global packages dependency. The one-liner is npm explore eslint -g -- npm i [email protected] in case you need to do that again. Sort of documented here => https://github.com/nodejs/node-gyp/wiki/Updating-npm's-bundled-node-gyp

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wincent picture wincent  ยท  7Comments

AuthorProxy picture AuthorProxy  ยท  6Comments

hzoo picture hzoo  ยท  3Comments

mondwan picture mondwan  ยท  7Comments

NotTooReact89 picture NotTooReact89  ยท  5Comments