Meteor-Angular2
Meteor-Angular2 copied to clipboard
ReferenceError: require is not defined
With as little document as there is, this is what I get : ReferenceError: require is not defined
. Do I need RequireJS, or something?
I believe this issue is related to a dependent package: netanelgilad:angular2-typescript
. You'll get it once for every file that has an import
statement, though the program will still run without issue. Angular2 isn't production ready & changes weekly, so I just accept an error or two in the console.
Could there be some more, very basic, documentations? Like what does System.import('client/app');
refers to (TypeScript file, template, etc.)? And perhaps the content for these files for a very basic usage?
You say that the program should run fine, but what I'm getting is in the console, where it says the app crashed. So, no, the app does not run just fine. And I don't have much dependencies.
Alright, I managed to find an example of a working project. It seems to not be crashing now :) I lost too much time on this, however :/
Sorry for the trouble. As specified in the readme, you have to pass in:
<body> <script>System.import('path/to/your/app');</script> </body>
Other than that, everything runs the same as any Angular 2 application.
There will be a tutorial coming soon. If you'd like to look at some early demos, look here.
I have probably the same problem. In the compiled js file, there is a require method call:
var angular2_1 = require('angular2/angular2');
Am I wrong if I place the source ts file into the client folder in my meteor app? I forgot to put this into the .ts file:
/// <reference path="typings/angular2/angular2.d.ts" />
If I put it in the .ts, the generated code is changed
var e = require("angular2/angular2"), t = function() { (...)
But the error message is the same.
Sorry if it's too lame.
I hope the issue with require
may be resolved as Meteor becomes more ES6 friendly. I'll look into a better solution.
Depending on which text editor or IDE you're using, the /// <reference path="path/to/angular2.d.ts" >
may not be necessary. I know that at least Atom, Visual Studio & Webstorm all automatically collect the definition files.
I think it's better to put the definition files outside of client
and server
so they will be used across the app.
But don't confused the .d.ts
files with the loaded code. They are just for development time error checking, like types and interfaces. The code is loaded by System.js in the final lines of the lib/angular2.dev.js
file.
Same problem.
Solved by upgrading npm typescript module in netanelgilad_angular2-typescript.
P.S. Thanks for tutorial! Great soft together ))
Wonderful! Have you thought about putting in a pull request on the netanelgilad_angular2-typescript
package?
It's updated on Github: https://github.com/netanelgilad/meteor-angular2-typescript/blob/e86a92b1af405f9e138c03818a45f93a019e2f37/package.js
But from Atmosphere loadining old version, so it was simple to upgrade ts "by hands".
I posted an issue to update the package on Atmosphere. Thanks again for sharing the fix!
Sorry guys, I can not catch up from the comments. I get the same error. I compile my ts files using eclipse, but I get this error in the browser. What did you have to do to get it resolved?