提问人:guirms 提问时间:10/23/2023 更新时间:10/23/2023 访问量:129
在 docker 上构建 Angular 映像时出现错误“process.nextTick(() => { throw err; });”
Error "process.nextTick(() => { throw err; });" when building Angular image on docker
问:
我有以下dockerfile
FROM node:latest AS build
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build
FROM nginx:alpine
COPY --from=build /app/dist/website-k8s/ /usr/share/nginx/html
EXPOSE 80
两周前,当我运行一切正常并且映像成功构建时。但是今天,当我尝试再次运行这个dockerfile时,我只收到以下错误:docker build -t imgTest .
Node.js version v21.0.0 detected.
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/releases/.
- Generating browser application bundles (phase: setup)...
#12 9.196 node:internal/event_target:1084
process.nextTick(() => { throw err; });
^
TypeError [Error]: Cannot read properties of undefined (reading 'indexOf')
at /app/node_modules/sass/sass.dart.js:104395:12
at Object.applyHooksTransformer (/app/node_modules/sass/sass.dart.js:1860:14)
at Object.initHooks (/app/node_modules/sass/sass.dart.js:1840:251)
at Object.initNativeDispatchContinue (/app/node_modules/sass/sass.dart.js:1806:9)
at Object.initNativeDispatch (/app/node_modules/sass/sass.dart.js:1800:9)
at Object.getNativeInterceptor (/app/node_modules/sass/sass.dart.js:25385:13)
at Object.getInterceptor$x (/app/node_modules/sass/sass.dart.js:25634:16)
at Object.set$compile$x (/app/node_modules/sass/sass.dart.js:25698:16)
at Object.main (/app/node_modules/sass/sass.dart.js:21090:9)
at main2 (/app/node_modules/sass/sass.dart.js:22875:9)
#12 9.200 Node.js v21.0.0
我的 angular 应用程序非常基础。我只有这个 HTML 文件app.component.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SimpleCalc</title>
</head>
<body>
<h1 class="title">SIMPLE CALCULATOR</h1>
<div class="calc-container">
<input class="calc-container--input" type="number">
<input class="calc-container--input" type="number">
<button *ngIf="this.num1 && this.num2" class="calc-container--btn">Get result</button>
</div>
</body>
</html>
此错误的原因可能是什么?
答:
0赞
guirms
10/23/2023
#1
Node 始终引用最新的可用节点版本,即现在的 21.x.x。如上所述,Node 21 目前与从 dart 编译为 js 的程序不兼容。
你需要改变
FROM node:latest AS build
自
FROM node:20-alpine AS build
通常,您应该使用特定版本来避免此类问题。
评论