Search code examples
angular2-cli

A2 CLI project runs locally but not remote after updating


I recently updated my global A2 CLI, as well as an existing project, to:

                             _                           _  _
  __ _  _ __    __ _  _   _ | |  __ _  _ __         ___ | |(_)
 / _` || '_ \  / _` || | | || | / _` || '__|_____  / __|| || |
| (_| || | | || (_| || |_| || || (_| || |  |_____|| (__ | || |
 \__,_||_| |_| \__, | \__,_||_| \__,_||_|          \___||_||_|
               |___/
@angular/cli: 1.0.0-beta.30
node: 7.4.0
os: darwin x64
@angular/common: 2.4.6
@angular/compiler: 2.4.6
@angular/core: 2.4.6
@angular/forms: 2.4.6
@angular/http: 2.4.6
@angular/platform-browser: 2.4.6
@angular/platform-browser-dynamic: 2.4.6
@angular/router: 3.4.6
@angular/cli: 1.0.0-beta.30
@angular/compiler-cli: 2.4.6

When I spin up ng serve on the project it runs fine but when I upload it to my vm I get the following errors:

[Error] SyntaxError: Unexpected token '<'
    (anonymous function) (inline.bundle.js:1)
[Error] SyntaxError: Unexpected token '<'
    (anonymous function) (polyfills.bundle.js:1)
[Error] ReferenceError: Can't find variable: webpackJsonp
    Global Code (styles.bundle.js:1)
[Error] SyntaxError: Unexpected token '<'
    (anonymous function) (vendor.bundle.js:1)
[Error] ReferenceError: Can't find variable: webpackJsonp
    Global Code (main.bundle.js:1)

This morning I created a new project and uploaded it to the vm without additional changes, to see if it was something in the project update, and I get the same errors.

Pretty stumped on what's going on here. This is the first time I've encountered it and my projects have worked fine locally and remotely before updating.

The remote system is a Windows Server 2012 with XAMPP.

My local system is a Mac, usually running the app via ng serve, but checked with MAMP and it works under Apache there, too.

Has anyone run across this?


Solution

  • So evidently it had something to do with the directory. The app runs in a subdirectory on my vm and that hasn't posed a problem in the past. When I changed the bas href from "/" to "./", it worked again.