angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Unexpected token import with Universal

Open Luca-Marantelli opened this issue 9 years ago • 4 comments

Bug Report or Feature Request (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.3.1 node: 8.2.1 os: win32 x64 @angular/animations: 4.3.5 @angular/cdk: 2.0.0-beta.8 @angular/common: 4.3.5 @angular/compiler: 4.3.5 @angular/core: 4.3.5 @angular/forms: 4.3.5 @angular/http: 4.3.5 @angular/material: 2.0.0-beta.8 @angular/platform-browser: 4.3.5 @angular/platform-browser-dynamic: 4.3.5 @angular/platform-server: 4.3.5 @angular/router: 4.3.5 @angular/cli: 1.3.1 @angular/compiler-cli: 4.3.5 @angular/language-service: 4.3.5

Repro steps.

Followed this tutorial: https://medium.com/@cyrilletuzi/angular-server-side-rendering-in-node-with-express-universal-engine-dce21933ddce At the end I run: node server.js

The log given by the failure.

D:\Test\frontend3>node server.js D:\Test\frontend3\node_modules@covalent\core\dialogs\dialog.component.js:10 import { Component, Directive, ContentChildren, QueryList } from '@angular/core' ; ^^^^^^

SyntaxError: Unexpected token import at createScript (vm.js:74:10) at Object.runInThisContext (vm.js:116:10) at Module._compile (module.js:533:28) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:503:32) at tryModuleLoad (module.js:466:12) at Function.Module._load (module.js:458:3) at Module.require (module.js:513:17) at require (internal/module.js:11:18) at Object.lwxD (D:\Test\frontend3\dist-server\main.bundle.js:1:952671)

Desired functionality.

Run server without errors

Mention any other details that might be useful.

I read then there can be problems with 3rd party libs, Is this problem related to that?

Luca-Marantelli avatar Aug 20 '17 10:08 Luca-Marantelli

I read then there can be problems with 3rd party libs, Is this problem related to that?

Yes, in this case Covalent has not refined their build processes to support commonjs. ~~You should submit an issue with them here~~ There is a long-running issue open on Covalent's GitHub page, it looks like they're actively working on it

CaerusKaru avatar Aug 20 '17 21:08 CaerusKaru

I have the same problem. Its been noted here

One option is to use webpack and whitelist ngx-bootstrap

dafabulousteach avatar Aug 21 '17 18:08 dafabulousteach

Duplicate of #7200.

hansl avatar Aug 21 '17 23:08 hansl

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.