5

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?

1
  • 1
    If you're using Angular CLI, you don't need to use ngc directly. You should use ng build --aot for AoT compilation. See this answer: stackoverflow.com/a/39167817/1377864 for more details. Commented Dec 31, 2016 at 11:30

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.