6
votes

I've got an application migrated from angular 2 to angular 5. When I deploy it locally and launch it via http-server I got no errors.

The problem occurs when I deploy it on my vm. After deployment when I open it in browser it throws the following errors:

TypeError: Object(...) is not a function at _isAndroid (forms.js:920)

Error: Uncaught (in promise): TypeError: Object(...) is not a function TypeError: Object(...) is not a function at _isAndroid (forms.js:920)

The deploy process in vm is as follows:

  1. Clone repository
  2. Install npm packages
  3. Build application via angular-cli
  4. Copy distribution folder on the relative path

My machines (local and vm) have the exact same npm 5.8.0, @angular-cli 1.7.3 and I don't use package-lock.json.

Finally I have to mention that before migration I had this exact same deployment process working.

Do you know what's possibly going wrong ?

Update

What I came up with is a brand new vm initialization (os, node, etc.)

2
Curious, are you building with AoT in both local and vm? - David Diefenderfer
No it's the default JiT - korteee
Maybe some package got updated and you've got a newer version on your vm? Try listing packages on both platforms and see the differences - David
@David I've tried cloning the repo and installing packages from scratch on my pc as well and I had no problems. - korteee
Did you compare the installed packages on both platforms? (npm ls) - David

2 Answers

0
votes

I don't believe Object static methods are available in Node 6.x (well, not without a flag) According to the Node website they are available in 7.x onwards.

See this page for details of the minimum version you need

As mentioned by ForestG, your best solution is to update your VM to Node 7.x or later.

0
votes

It looks like either minification issue due to missing ; or aggressive optimization or file is corrupted, but difficult to reason without source code.

Example:

//without minification works ok
function test() {
      var postTypes = new Array('hello', 'there')   
      (function() { alert('hello there') })()
}

//after minification produces error Uncaught TypeError: object is not a function
function test() {
      var postTypes = new Array('hello', 'there')(function() { alert('hello there') })()
}