Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel._util undefined #52

Closed
john-cheesman opened this issue Feb 27, 2015 · 5 comments
Closed

babel._util undefined #52

john-cheesman opened this issue Feb 27, 2015 · 5 comments

Comments

@john-cheesman
Copy link

Since Babel updated to 4.6.0 I've been getting this error in my build. It was working fine yesterday and nothing else has changed on my local setup (it broke the build on the server, which runs npm install every time). The only option I'm passing is ignore, like this:

return browserify(filename)
            .transform(babelify
                .configure({
                    ignore: 'node_modules'
                }))
            .bundle();

Removing the configure method from here fixes the build, otherwise I get this:

C:\Users\John\Sites\MyAccountWeb\node_modules\babelify\index.js:14
  if (opts.ignore) opts.ignore = babel._util.regexify(opts.ignore);
                                             ^
TypeError: Cannot call method 'regexify' of undefined
    at Function.browserify.configure (C:\Users\John\Sites\MyAccountWeb\node_modules\babelify\index.js:14:46)
    at C:\Users\John\Sites\MyAccountWeb\gulp\tasks\scripts.js:21:18
    at Transform.write [as _transform] (C:\Users\John\Sites\MyAccountWeb\node_modules\vinyl-transform\index.js:13:18)
    at Transform._read (C:\Users\John\Sites\MyAccountWeb\node_modules\vinyl-transform\node_modules\through2\node_modules
\readable-stream\lib\_stream_transform.js:184:10)
    at Transform._write (C:\Users\John\Sites\MyAccountWeb\node_modules\vinyl-transform\node_modules\through2\node_module
s\readable-stream\lib\_stream_transform.js:172:12)
    at doWrite (C:\Users\John\Sites\MyAccountWeb\node_modules\vinyl-transform\node_modules\through2\node_modules\readabl
e-stream\lib\_stream_writable.js:237:10)
    at writeOrBuffer (C:\Users\John\Sites\MyAccountWeb\node_modules\vinyl-transform\node_modules\through2\node_modules\r
eadable-stream\lib\_stream_writable.js:227:5)
    at Transform.Writable.write (C:\Users\John\Sites\MyAccountWeb\node_modules\vinyl-transform\node_modules\through2\nod
e_modules\readable-stream\lib\_stream_writable.js:194:11)
    at write (C:\Users\John\Sites\MyAccountWeb\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_module
s\readable-stream\lib\_stream_readable.js:623:24)
    at flow (C:\Users\John\Sites\MyAccountWeb\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules
\readable-stream\lib\_stream_readable.js:632:7)

I was ignoring node_modules to avoid Angular being processed and causing problems but it seems to be fine now without any config, does it ignore stuff by default now?

Thanks

@saschagehlich
Copy link

Same for me!

@simonzack
Copy link

babel._util is not exported I think so babel._util.regexify is giving undefined.

https://github.com/babel/babel/blob/4df9cf6c0516551edba96601cc272e2936e7addc/src/babel/api/node.js#L5.

@simonzack
Copy link

babel.transform is suffering from the same problem.

@andrewlmurray
Copy link

So in package.json it looks like babelify is pinned to use anything newer than 4.0.0 of babel core.
If 5.0.3 is broken for you is purely a function of when you installed it. (I originally installed 5.0.3 a couple weeks ago and it was fine, tried to use the same project on a different machine with a clean install and it is broken) This is due to the fact that which version of babel-core you get isn't fixed.

For all new installers (who aren't pinning a version of babel-core in their dev dependencies) 5.0.3 will be broken. (Unless a new version of babel is released that exposes ._util in babel-core)

Perhaps it is worth just pinning to a stable version of babel-core in dev-dependencies and upgrading it in lockstep with babelify releases? It seems this would prevent errors of this form - I'm unsure if there would be undesirable effects form such a scheme.

You can fix this locally for now by pinning babel-core in your dev-dependencies to 4.3.0

devDependencies": {
    "babel-core": "4.3.0",
    "babelify": "5.0.3",
...

@sebmck
Copy link

sebmck commented Feb 28, 2015

Should be fixed as of Babel 4.6.1, sorry everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@andrewlmurray @saschagehlich @simonzack @sebmck @john-cheesman and others