ng构建无法找到可用的模块

时间:2019-05-03 13:44:38

标签: javascript angular typescript

我正在使用一个两步构建过程,该过程包括创建一个包含所有节点模块的docker映像,这是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

此docker镜像用于在第二步中通过执行构建脚本来构建angular应用

#!/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

所有代码都安装到/ workspace文件夹中。 ls的输出是:

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

据我所知,node_modules文件夹包含所有预期的文件夹。 运行此命令时,出现以下错误:

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'.

当我检查该模块时,该模块位于node_modules目录中。找不到该模块的原因可能是什么?

0 个答案:

没有答案