在为我的Angular项目执行docker build时,在npm ci步骤中,我得到以下错误:Cannot read property '@angular/animations' of undefined
由于没有适当的错误,我们无法找到解决办法。
包和节点版本:
- @angular/animations - 15.2.9
- Node.Js - 18.14.2
- NPM - 9.5
- Angular Cli - 15.2.8
到目前为止我一直在尝试: - 交叉检查Animations模块的package.json文件
- 尝试降级@angular/animations版本
- 正在删除package-lock.json文件和node_module目录
- 正在删除缓存并尝试
DockerFile:
FROM docker-images.artifactory.dummydomain.com/db/node:14.18-alpine as build
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm install -g @angular/cli@15.2.8
RUN npm ci
RUN ng build --configuration=test
USER node
COPY --chown=node:node . .
Package.json文件依赖:
"@angular/animations": "^15.2.9",
"@angular/cdk": "^15.2.9",
"@angular/common": "^15.2.9",
"@angular/compiler": "^15.2.9",
"@angular/core": "^15.2.9",
"@angular/forms": "^15.2.9",
"@angular/localize": "^15.2.9",
"@angular/material": "^15.2.9",
"@angular/material-moment-adapter": "^15.2.9",
"@angular/platform-browser": "^15.2.9",
"@angular/platform-browser-dynamic": "^15.2.9",
"@angular/router": "^15.2.9",
"angular-in-memory-web-api": "^0.9.0",
"core-js": "^3.6.2",
"export-from-json": "^1.7.0",
"hammerjs": "^2.0.8",
"material-design-icons-iconfont": "^6.7.0",
"moment": "^2.24.0",
"ng-uikit-pro-standard": "^1.0.0",
"ngx-spinner": "^15.0.1",
"rxjs": "~6.6.7",
"socket.io-client": "^4.5.4",
"sweetalert2": "^11.6.9",
"tslib": "^2.0.0",
"vkbeautify": "^0.99.3",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.2.8",
"@angular/cli": "^15.2.8",
"@angular/compiler-cli": "^15.2.9",
"@angular/language-service": "^15.2.9",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.8.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.4.2",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.7.0",
"protractor": "~7.0.0",
"ts-node": "~7.0.0",
"tslint": "~6.1.0",
"typescript": "~4.9.5"
}
如果有人能帮忙就太好了。TIA!
1条答案
按热度按时间k4emjkb11#
如果npm试图处理它无法理解的锁文件,就会发生此错误(错误消息根本没有帮助)。锁文件的格式会随着时间的推移而变化,npm在锁文件中使用
lockfileVersion
参数标记当前版本:您使用v14.18作为基础映像,它随npm v6一起提供。在你的系统中,你有npm v9,所以
lockfileVersion
是3。正如你在上面的列表中看到的,这种格式与npm v6不兼容。建议的修复方法是将Node基本映像的版本更新为v16(npm 8)或v18(npm 9)。或者,您可以使用npm v8执行
npm install
,并提交+推送生成的锁文件。