Dockerize angular-cli 4项目在尝试运行“ng build –aot –prod”时失败

我正在尝试使用以下docker文件dockerize我的angular-cli项目:我确实遵循了以下步骤:

https://github.com/avatsaev/angular4-docker-example

—- DOCKER文件——

FROM nginx:1.13-alpine ENV APP_PATH /app ENV PATH $APP_PATH/node_modules/@angular/cli/bin/:$PATH RUN apk add --update --no-cache nodejs && mkdir $APP_PATH && rm -rf /etc/nginx/conf.d/* WORKDIR $APP_PATH COPY . . COPY nginx/default.conf /etc/nginx/conf.d/ ARG NPM_TOKEN COPY .npmrc .npmrc COPY package.json package.json RUN npm install ng build --aot --prod \ && rm -rf /usr/share/nginx/html/* \ && mv ./dist/* /usr/share/nginx/html/ \ && npm cache clean \ && apk del nodejs libstdc++ libgcc libuv http-parser ca-certificates \ && rm -rf ./* CMD ["nginx", "-g", "daemon off;"] 

它下载软件包,运行npm install罚款,并且在“build build –aot –prod”上失败,它成功下载所有的软件包,包括打字稿不知道为什么它在这里失败,我没有从exception中得到任何线索什么在这里是错误的:

 module.js:471 throw err; ^ Error: Cannot find module 'typescript' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (/app/node_modules/@angular/cli/models/config/config.js:5:12) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) 

package.json中的一个包是指私人registry我的错误是,而不是标签私人registry只为该包我做了一个全球标记在我的.npmrc文件,看起来像

 "registry=URl private registry" 

这应该是

 "scope:registry=URL for private registry" 

所以它是从私人registry下载公共软件包,因为某些原因没有按预期下载某些模块。 这就是为什么我越来越Cannot find module 'typescript' error 。 同时,由于多次重试,我的.npmrc文件中的授权令牌被损坏,我不确定如何对接,我不得不删除该文件并再次撤消令牌,并做一个新的npm install使其工作。 以下链接有关于npm令牌的信息和下载docker的私人包裹。 我希望这有助于在任何人遇到类似的问题。

https://docs.npmjs.com/private-modules/ci-server-config