Error: SyntaxError: Unexpected token import
Hello, im working with 2.0.0-beta.5-preview, updated my project to the angular 2 final and i get the following error:
Error: SyntaxError: Unexpected token import
the line that generate this error is a compiled js from typescript, with the following line:
var angularfire2_1 = require('angularfire2');
There's nothing wrong in the logs, and if i remove the angularfire from my project it runs just fine.
Relevant files: package.json
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@types/request": "0.0.30",
"angularfire2": "^2.0.0-beta.5-preview",
"core-js": "^2.4.1",
"firebase": "^3.4.0",
"ntypescript": "1.201609060105.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"concurrently": "^2.2.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.2",
"typings": "^1.3.2"
}
}
system.config.js
/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: '/app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'angularfire2': 'npm:angularfire2',
// other libraries
'rxjs': 'npm:rxjs',
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
angularfire2: {
main: 'angularfire2.js',
format: 'cjs',
defaultExtension: 'js'
},
'angular2-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
}
}
});
})(this);
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"typeRoots": [
"../node_modules/@types"
],
// ADD THIS
"types": [
"firebase"
]
}
}
@hllink can you change the angularfire2 configuration in SystemJS to this:
{
main: 'index.js',
format: 'esm',
defaultExtension: 'js'
}
This is due to us changing the module format shipped in the root of the directory to ESM instead of CommonJS to be consistent with the rest of Angular.
@jeffbcross hi, thank you for the attention.
when i change the SystemJS i got the following error:

the file http://localhost:3000/node_modules/angularfire2/index.js do exists and has the following content:
export * from './angularfire2';
//# sourceMappingURL=index.js.map
Updated angular-cli to version 1.0.0-beta.15 and it solved the issue, gonna close it now, thanks for the support.