I've tried installing the Angular compiler-cli (ngc) using:
npm install @angular/compiler-cli typescript @angular/platform-server @angular/compiler
And the install appears to have worked, but now when I run ngc -p src
, per the solution to this question, I get:
module.js:442
throw err;
^
Error: Cannot find module '@angular/core'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at /usr/local/lib/node_modules/@angular/compiler/bundles/compiler.umd.js:7:83
at Object.<anonymous> (/usr/local/lib/node_modules/@angular/compiler/bundles/compiler.umd.js:10:2)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
My project runs fine with ng serve
. What am I doing wrong here?
If you're using Angular CLI already, just use ng build
and let that worry about calling ngc
correctly.
If this is about AOT, then do this:
ng build -prod -aot
and your /dist/
folder will contain what you need.
Edit: I should add that the question you linked to is for RC5, when Angular CLI was still an infant. There were so many changes since, it's best to always look for answers based on Final.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With