I'm had quite a hard time installing angular2 and setting it up locally using Babel
and Webpack
to reimplement a simple Hello world
app in angular ponents, just to get started.
I'm currently having this runtime error:
index.html:9 Uncaught TypeError: Cannot read property 'Version' of undefined
if you are curious.
Here's a sexy image illustrating the situation.
I tried to figure out where this error occured and it turns out it's angular (correct me if I'm wrong).
This line to be exact, var VERSION=new _angular_core.Version(\"2.4.8\") ...
.
Can I get some help please ? Thanks !!
appponent.js
import {Component} from '@angular/core';
@Component({
selector: 'my-app',
template: `
<h1>Hello Angular 2</h1>
`
}) export class AppComponent {};
app.module.js
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './appponent'
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
}) export class AppModule {};
main.js
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
index.js
require('!!script-loader!@angular/piler/bundles/piler.umd.min.js');
require('!!script-loader!@angular/core/bundles/core.umd.min.js');
require('!!script-loader!@angular/mon/bundles/mon.umd.min.js');
require('!!script-loader!@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.min.js');
require('!!script-loader!rxjs/bundles/Rx.min.js');
require('./main')
I'm had quite a hard time installing angular2 and setting it up locally using Babel
and Webpack
to reimplement a simple Hello world
app in angular ponents, just to get started.
I'm currently having this runtime error:
index.html:9 Uncaught TypeError: Cannot read property 'Version' of undefined
if you are curious.
Here's a sexy image illustrating the situation.
I tried to figure out where this error occured and it turns out it's angular (correct me if I'm wrong).
This line to be exact, var VERSION=new _angular_core.Version(\"2.4.8\") ...
.
Can I get some help please ? Thanks !!
app.ponent.js
import {Component} from '@angular/core';
@Component({
selector: 'my-app',
template: `
<h1>Hello Angular 2</h1>
`
}) export class AppComponent {};
app.module.js
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './app.ponent'
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
}) export class AppModule {};
main.js
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
index.js
require('!!script-loader!@angular/piler/bundles/piler.umd.min.js');
require('!!script-loader!@angular/core/bundles/core.umd.min.js');
require('!!script-loader!@angular/mon/bundles/mon.umd.min.js');
require('!!script-loader!@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.min.js');
require('!!script-loader!rxjs/bundles/Rx.min.js');
require('./main')
Share
Improve this question
edited Mar 1, 2017 at 10:29
Noctisdark
asked Feb 21, 2017 at 18:47
NoctisdarkNoctisdark
3483 silver badges17 bronze badges
3
-
it means that there's nothing called
new _angular_core
, could you please share more codes ? how do you think we could know what is it reallyvar VERSION=new _angular_core.Version(\"2.4.8\")
?? – SeleM Commented Feb 21, 2017 at 20:54 - 1 @5313M Done, sorry for not providing the code from the start. Thanks – Noctisdark Commented Feb 22, 2017 at 6:45
- 1 can you share your code in plunker – Ravin Singh D Commented Feb 28, 2017 at 7:49
3 Answers
Reset to default 6Perhaps you could start your first projects using Angular CLI. It saves you the trouble of having to set up an entire development environment. A decent setup is provided by the Angular team. You can install it using by running 'npm install -g @angular/cli'.
You can then create a new project with the mand 'ng new PROJECT_NAME' and run it with the mand 'ng serve'. That's really all there is to it :-) Have a look at the docs to get you up and running here: https://github./angular/angular-cli
When you feel confident about your project and wish to get your hands dirty with the build configs (based on webpack!), use the 'ng eject' mand.
All your angular packages should be at the same version. Which means core mon piler etc. should all be 2.4.8.
The problem is that I think before 2.2 or 2.3 of Angular this get version didn't exist. So if you have lets say @angular/core
at 2.2 and @angular/mon
at 2.4.8 then @angular/mon
might use features of @angular/core
which don't exist in that older version of @angular/core
yet like for example maybe angular.core.getVersion()
To get angular's version:
import * as angular2 from 'angular2/angular2';
console.log(angular2.version);
https://github./angular/angular/issues/1357