Search code examples
javascriptnode.jsangularubuntuionos

Angular on IONOS(?) throws an error with npm


I'm trying use npm install @angular/cli to install Angular on my managed Webhosting (No root-rights) at IONOS (Germany).

I was able to install NodeJS/npm with nvm, but now every time I try to install Angular I get the following error:

\~$ npm install @angular/cli

\[..................\] \\ idealTree:htdocs: sill idealTree buildDeps

\<--- Last few GCs ---\>

\[2654145:0x5267850\]      731 ms: Scavenge 46.9 (67.5) -\> 39.3 (67.1) MB, 4.4 / 0.0 ms  (average mu = 0.985, current mu = 0.985) task;

\<--- JS stacktrace ---\>

FATAL ERROR: NewSpace::Rebalance Allocation failed - JavaScript heap out of memory

 1: 0xb9a300 node::Abort() \[npm install @angular/cli\]

 2: 0xaa0794  \[npm install @angular/cli\]

 3: 0xd71e20 v8::Utils::ReportOOMFailure(v8::internal::Isolate\*, char const\*, bool) \[npm install @angular/cli\]

 4: 0xd721c7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate\*, char const\*, bool) \[npm install @angular/cli\]

 5: 0xf4f585  \[npm install @angular/cli\]

 6: 0xfabbc9  \[npm install @angular/cli\]

 7: 0xfabc28 v8::internal::MarkCompactCollector::CollectGarbage() \[npm install @angular/cli\]

 8: 0xf5f3b1 v8::internal::Heap::MarkCompact() \[npm install @angular/cli\]

 9: 0xf60e88  \[npm install @angular/cli\]

10: 0xf617f8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) \[npm install @angular/cli\]

11: 0xf647d2 v8::internal::Heap::AllocateExternalBackingStore(std::function\<void\* (unsigned long)\> const&, unsigned long) \[npm install @angular/cli\]

12: 0x1088d52 v8::internal::BackingStore::Allocate(v8::internal::Isolate\*, unsigned long, v8::internal::SharedFlag, v8::internal::InitializedFlag) \[npm install @angular/cli\]

13: 0xddceb8  \[npm install @angular/cli\]

14: 0xddd381 v8::internal::Builtin_ArrayBufferConstructor(int, unsigned long\*, v8::internal::Isolate\*) \[npm install @angular/cli\]

15: 0x1710779  \[npm install @angular/cli\]

Aborted

I also tryed using npm install -g --max-old-space-size=1016 @angular/cli , which resulted in the same error. And I tryed it on node v20, 19 and 18

I'm fairly new to Angular and this is my first deployment. And I'm sadly stuck in this managed hosting for another 6 or so months:(

Does anybodey know how to get it working?


Solution

  • Run the following command in your project directory: ng build --prod. This will create folder called "dist" in your project directory containing the production-ready files, which you then can upload to your webserver.

    more details: https://angular.io/guide/deployment