Angular AOT build error: Cannot find module 'utils/utils'


#1

I’m getting a build build error for Angular 4 AOT builds: Cannot find module ‘utils/utils’. I’m importing into the component like so:
import * as utils from ‘utils/utils’;

I’m only getting the error on AOT builds. I’m using utils to open a web page and it is working without issues:
utils.openUrl(linkURL);

Any help would be appreciated


#2

Are you sure it’s that, because I have been using utils and same method in Angular 4 and 5 now. Never had an issue with AOT compilation.


#3

Not sure what version of NativeScript Webpack that you’re using, but if you’ve upgraded to 0.9.x, have you gone through these steps: https://www.nativescript.org/blog/nativescript-webpack-0.9.0-what-changed-and-how-to-upgrade

If not, maybe now is the time to upgrade some tools/dependencies?


#4

I was able to fix it by using:
import * as utils from ‘tns-core-modules/utils/utils’;

instead of:
import * as utils from ‘utils/utils’;