Losing reference depending which file was last saved

Hi, I’m new in Ionic and I’m facing a very strange situation here which I don’t know if it is a bug or if I need to do some kind of configuration.

The problem is so odd that is hard to even explain, but I will try.

Let’s say that I create a page named ‘page1’ which generate the files page1.html, page1.ts, page1.module.ts and page1.scss. I start the ionic serve I write some code in page1.ts and page1.html. I save the HTML file and then after the TS file. ionic serve refresh the app in the browser with my modifications and everything goes OK. But if I go to the HTML file and just pres CTRL-S to save it with no modification, ionic serve updates the app on the browser then I got a reference error, this error can be anything, a function or variable that exists on TS file and the HTML file just don’t recognize it anymore, then I go to TS file and press CTRL-S again to save it with no modification, ionic serve reloads the app and now it works again.

Summing up, if I save the HTML file to force a reload I got an error, if I save the TS file to force a reload the app works.

The problem is that my project is growing up and now I have to pay attention in the sequence which I save the files, because looks like that if the HTML file of a page or component is saved after the TS file I got an error.

It is very annoying and improductive situation.

Is there anyone that face a problem like that? What can I do here to solve it?

Following some environment information:

Ionic version: 3.19.1
NPM version: 5.6.0
Angular CLI: 1.6.7
Node: 9.5.0
OS: win32 x64
Cordova: 8.0.0
Phonegap: 7.1.1
Visual Studio Code: 1.20

Thank you very much.

I don’t know if ionic completely supports node 9.5.0 yet. You could try to downgrade it to the stable version. Usually there is no need to install phonegap or angular cli for an ionic project. If you don’t work on angular or phonegap projects you could delete them. Do you use unusual names for your files? Maybe that could cause the error, too.

Hi Nexi. I downgrade my NodeJs to the version 8.9.4 and uninstall the phonegap and now it is working.
Looks like the real problem was the version of the NodeJs.

Thank you very much.

I was going to recommend Node downgrade too. In general, you want to stay with the current LTS, which will always be an even number. Node 9 in particular has a history of being incompatible with SASS, which will cause weird behavior when rebuilding a template.,

1 Like