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

[1.3.3] Upgrade breaks app, 'require is not defined' #7226

Closed
holmrenser opened this issue Jun 15, 2016 · 5 comments
Closed

[1.3.3] Upgrade breaks app, 'require is not defined' #7226

holmrenser opened this issue Jun 15, 2016 · 5 comments
Assignees

Comments

@holmrenser
Copy link

After upgrading to 1.3.3 using meteor update my app instantly crashes.
Working on mac.

(STDERR)           
(STDERR) /Users/rensholmer/.meteor/packages/meteor-tool/.1.3.3.1ryifg6++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
(STDERR)                        throw(ex);
(STDERR)                              ^
(STDERR) ReferenceError: require is not defined
(STDERR)     at Package (packages/electronifiejs_pages.js:45:16)
(STDERR)     at packages/electronifiejs_pages.js:1296:4
(STDERR)     at packages/electronifiejs_pages.js:1303:3
(STDERR)     at /Users/rensholmer/Documents/Code/NODE/meteor/portal/.meteor/local/build/programs/server/boot.js:291:10
(STDERR)     at Array.forEach (native)
(STDERR)     at Function._.each._.forEach (/Users/rensholmer/.meteor/packages/meteor-tool/.1.3.3.1ryifg6++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
(STDERR)     at /Users/rensholmer/Documents/Code/NODE/meteor/portal/.meteor/local/build/programs/server/boot.js:133:5
=> Exited with code: 8
@benjamn
Copy link
Contributor

benjamn commented Jun 15, 2016

What version were you updating from?

@holmrenser
Copy link
Author

holmrenser commented Jun 15, 2016

1.3.2

@benjamn
Copy link
Contributor

benjamn commented Jun 15, 2016

This appears to be a consequence of changes to the coffeescript package in Meteor 1.3.3 that allow raw JavaScript enclosed by back-ticks to be compiled using babel-compiler.

Unfortunately, sometimes Babel adds require calls to the code that it generates, in an attempt to fix certain runtime problems, or implement new ES2015 features.

Since the electronifiejs:pages package contains a file that contains back-ticks, that file is passed through Babel, and ends up with require("babel-runtime/helpers/typeof") at the top.

But since electronifiejs:pages does not use the modules package, it doesn't have the require function, which leads to your error.

This is definitely a bug in the coffeescript package that should be fixed, but that will have to wait for the next coffeescript release.

In the meanwhile, I can think of two ways to fix this. Both approaches involve installing electronifiejs:pages locally, so do this first:

cd path/to/app
mkdir packages
cd packages
git clone https://github.com/electronifie/meteor-pages.git

Now that you have a local copy of electronifiejs:pages, you can either

  1. (less recommended) make electronifiejs:pages use the modules package, by adding api.use("modules") to the Package.onUse section of path/to/app/packages/meteor-pages/package.js, or
  2. (more recommended) remove the back-ticks from that line in pages.coffee:
diff --git a/lib/pages.coffee b/lib/pages.coffee
index 66337ee..af84f94 100755
--- a/lib/pages.coffee
+++ b/lib/pages.coffee
@@ -103,7 +103,7 @@

   constructor: (collection, settings = {}) ->
     unless @ instanceof Meteor.Pagination
-      throw new Meteor.Error "missing-new", "The Meteor.Pagination instance has to be initiated with `new`"
+      throw new Meteor.Error "missing-new", "The Meteor.Pagination instance has to be initiated with new"

     # Instance variables

@benjamn benjamn self-assigned this Jun 15, 2016
@holmrenser
Copy link
Author

holmrenser commented Jun 16, 2016

Thanks for this workaround! This fixed the problem, however in the end I simply removed electronifiejs:pages and implemented paging myself.

gantrim added a commit to gantrim/meteor-pages that referenced this issue Jun 17, 2016
In meteor 1.3.3 (possibly other versions) the backticks caused ReferenceError: require is not defined when including this package. switched backticks to single quotes per suggestion here: meteor/meteor#7226
@benjamn benjamn added this to the Release 1.3.3.1 milestone Jun 17, 2016
@benjamn benjamn mentioned this issue Jun 17, 2016
5 tasks
benjamn pushed a commit that referenced this issue Jun 17, 2016
@benjamn
Copy link
Contributor

benjamn commented Jun 17, 2016

This should be fixed in Meteor 1.3.3.1, which you can try by running meteor update --release 1.3.3.1. Feel free to reopen if the problem happens again.

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

No branches or pull requests

2 participants