I am using a two step build process which consists of creating a docker image containing all node modules, this is the dockerfile:

FROM johnpapa/angular-cli:latest

WORKDIR /workspace

COPY package.json /tmp/package.json
COPY .npmrc /tmp
RUN cd /tmp && npm install

COPY build.sh .
RUN chmod +x build.sh

This docker image is used to then build the angular app in the second step by executing the build script

#!/bin/bash

# Copy the code in the workspace to the node_modules
echo "Copy workspace into tmp folder (where node_modules are located)"
cp -r /workspace/. /tmp

ls /tmp

# Build the app
echo "Build app"
cd /tmp
ng build --prod --no-progress

# Copy the build
echo "Copy build back into workspace"
cp -r /tmp/dist /workspace

All code is mounted to the /workspace folder. The output of the ls is:

README.md
angular.json
build.sh
config
e2e
node_modules
package-lock.json
package.json
src
tsconfig.json
tslint.json

The node_modules folder contains all expected folders as far as I can tell. When I run this I get the following error:

Date: 2019-05-03T12:44:20.272Z
Hash: 10d6f4b1fea067545117
Time: 16899ms
chunk {0} runtime.26209474bfa8dc87a77c.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.01ecbc0fcff9207e8cde.js (main) 128 bytes [initial] [rendered]
chunk {2} polyfills.a723c36635c3a098c2aa.js (polyfills) 130 bytes [initial] [rendered]
chunk {3} styles.c6fec78ef998cf076081.css (styles) 162 kB [initial] [rendered]
chunk {scripts} scripts.5839c9878608484a7aa9.js (scripts) 20.3 kB [entry] [rendered]

ERROR in app/app.module.ts(168,5): Error during template compile of 'AppModule'
Could not resolve angular-gauge-chart relative to /tmp/src/app/app.module.ts..
src/app/app.module.ts(65,34): error TS2307: Cannot find module 'angular-gauge-chart'.

That module is in the node_modules directory when I check it. What could be the cause of it not finding that module?

0 Answers