Angular2 build process freezes on windows

2019-09-05 02:35发布

问题:

I'm trying to build angular2 on windows 10, but the build freezes after starting !build.js.cjs. The build freezes my terminal to the point where ctrl-c does not work and I have to close the terminal (or kill node in task manager) end it.

Running gulp broccoli.js.dev also freezes, so the issue might be in the broccoli task.

I have tried multiple versions of node, but I've not made any progress.

Dart SDK is not available, Dart tasks will be skipped.
[11:30:21] Using gulpfile ~\Documents\angular\gulpfile.js
[11:30:21] Starting 'build/clean.js'...
[11:30:21] Starting 'build/clean.tools'...
[11:30:21] Starting 'build/clean.dart'...
Dart SDK is not available. Skipping task: build/clean.dart
[11:30:21] Finished 'build/clean.dart' after 271 μs
[11:30:21] Starting 'build/clean.docs'...
[11:30:21] Starting 'build/clean.bundles'...
[11:30:21] Starting 'build/clean.bundles.benchpress'...
[11:30:21] Finished 'build/clean.docs' after 26 ms
[11:30:21] Finished 'build/clean.bundles' after 26 ms
[11:30:21] Finished 'build/clean.bundles.benchpress' after 26 ms
[11:30:21] Finished 'build/clean.js' after 56 ms
[11:30:21] Starting 'build.js.dev'...
[11:30:21] Finished 'build/clean.tools' after 59 ms
[11:30:21] Starting 'build.tools'...
[11:30:21] Starting '!build.tools'...
[11:30:21] Starting 'clean'...
[11:30:21] Finished 'clean' after 4.46 μs
[11:30:22] Starting '!bundle.ng.polyfills'...
[11:30:22] Starting '!bundles.js.docs'...
[11:30:22] Finished '!bundles.js.docs' after 112 ms
[11:30:22] Finished '!bundle.ng.polyfills' after 315 ms
[11:30:24] Finished '!build.tools' after 2.86 s
[11:30:24] Finished 'build.tools' after 2.86 s
[11:30:24] Starting 'broccoli.js.dev'...
[11:30:24] Starting '!broccoli.js.dev'...
[11:30:24] Starting 'build.js.prod'...
[11:30:24] Starting '!broccoli.js.prod'...
[11:30:24] Starting 'build.js.cjs'...
[11:30:24] Starting '!build.js.cjs'...

回答1:

update

doesn't apply to recent Angular2 versions because the build process was changed a lot

original

I created a Dockerfile to build Angular2 that might be of some help (needs a VM to run on Windows though)

FROM google/debian:jessie

MAINTAINER Günter Zöchbauer <gunter@gzoechbauer.com>

RUN echo "deb http://ftp.de.debian.org/debian/ jessie main non-free contrib" >> /etc/apt/sources.list

RUN \
  apt-get -q update && \
  DEBIAN_FRONTEND=noninteractive && \
  apt-get install --no-install-recommends -y -q \
    curl \
    git \
    git-core \
    # npm \ 1.4.21 but requires >= 3.5.3 < 4.0.0
    # nodejs \ 0.10.29 but requires >=5.4.1 < 6.0.0
    apt-transport-https \
    ca-certificates \
    make \
    build-essential \
    g++ && \
  apt-get upgrade -y

RUN \
  curl -sL https://deb.nodesource.com/setup_5.x | bash - && \
  apt-get install -y nodejs

RUN \
  sh -c 'curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' && \
  # Set up the location of the stable repository.
  sh -c 'curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list' && \
  apt-get update && \
  DEBIAN_FRONTEND=noninteractive && \
  apt-get install --no-install-recommends -y -q \
    dart/stable

ENV DART_SDK /usr/lib/dart
ENV PATH $DART_SDK/bin:$PATH

RUN git clone --recursive https://github.com/angular/angular.git

WORKDIR /angular


RUN \
  npm install bower -g && \
  npm install tsd -g

RUN \
  npm install && \
  bower --allow-root install && \
  cd tools && npm install && tsd install && \
  cd ../modules/angular2 && npm install && tsd install

RUN node --max-old-space-size=4096 $(npm bin)/gulp build