babel / babelify

Browserify transform for Babel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read property 'canCompile' of undefined

alessioalex opened this issue · comments

Hey there, tried babelify and it didn't work. Installed according to the readme instructions but something breaks, I have no idea why.

 alessio: /home/alessio/www/ftplrs git:master
→ npm install babelify @babel/core
npm WARN ftplrs@1.0.0 No description
npm WARN ftplrs@1.0.0 No repository field.

+ babelify@8.0.0
+ @babel/core@7.1.2
updated 2 packages in 1.388s

 alessio: /home/alessio/www/ftplrs git:master
→ npm i @babel/preset-env
npm WARN ftplrs@1.0.0 No description
npm WARN ftplrs@1.0.0 No repository field.

+ @babel/preset-env@7.1.0
updated 1 package in 3.672s

 alessio: /home/alessio/www/ftplrs git:master
→ browserify index.js -t [ babelify --presets [ @babel/preset-env ] ]
/home/alessio/www/ftplrs/node_modules/babelify/index.js:65
    if (!babel.util.canCompile(filename, extensions)) {
                    ^

TypeError: Cannot read property 'canCompile' of undefined
    at /home/alessio/www/ftplrs/node_modules/babelify/index.js:65:21
    at Babelify (/home/alessio/www/ftplrs/node_modules/babelify/index.js:10:36)
    at nr (/home/alessio/.nvm/versions/node/v8.9.2/lib/node_modules/browserify/node_modules/module-deps/index.js:311:23)
    at onfile (/home/alessio/.nvm/versions/node/v8.9.2/lib/node_modules/browserify/node_modules/resolve/lib/async.js:59:21)
    at onex (/home/alessio/.nvm/versions/node/v8.9.2/lib/node_modules/browserify/node_modules/resolve/lib/async.js:107:32)
    at /home/alessio/.nvm/versions/node/v8.9.2/lib/node_modules/browserify/node_modules/resolve/lib/async.js:10:20
    at FSReqWrap.oncomplete (fs.js:153:5)

Nevermind I think I mixed packages I should have installed.

Dude, what was causing the problem?

Installed different modules from different readmes instead of sticking to the ones from the current README I think. I removed node_modules, re-read and followed the instructions and it worked.

Thanks bro, my issue was install outdated packages that Typescipt Gulp Tutorial suggest to install. At the end, i was working with babelify@8, and babel ^7.5.5, and they aren't compatible. So i've installed babelify@10 and everything worked well.

@geanfrancovolpe thank you so much for the solution! I was messing around from an hour already and nothing was working then I've updated to babelify@10 as you said and it worked! Cheers :D