Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module './$data' when building Angular2 application

Tags:

angular

I am trying to compile an Angular2 application and getting this error when I issue ng serve command:

C:\Projects\All\MyAngularApp>ng serve
Cannot find module './$data'
Error: Cannot find module './$data'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Projects\All\MyAngularApp\node_modules\ajv\lib\ajv.js:10:23)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Projects\All\MyAngularApp\node_modules\schema-utils\dist\validateOptions.js:15:12)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)

Is there a good resource that explains how to debug these issues?

This is not the first time we are getting these build errors, but previously we were able to resolve them by running npm install command.

like image 511
myroslav Avatar asked Feb 17 '26 02:02

myroslav


1 Answers

It happened to me because our build definition requires node_modules to be checked in. I got three errors because of this from har-validator\node_modules\ajv\lib, schema-utils\node_modules\ajv\lib, and webpack\node_modules\ajv\lib. I manually deleted ajv\lib from source control (and ofc locally) the build then succeeded.

Hope this helps.

like image 185
Nathan Avatar answered Feb 19 '26 00:02

Nathan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!