我有一个NestJs项目,是建立在码头在gitlab CI。
在本地,dockerfile构建得非常好,包括:
docker build -t server .
但是在gitbal CI中,使用相同的对接器和相同的命令,它就会崩溃。尤其是@nestjs/common。)我了解到码头在每个环境中都是以同样的方式工作的。)
这是我的Dockerfile:
FROM node:17-stretch-slim As builder
WORKDIR /app
COPY *.json *.ts ./
RUN npm install npm@8.5.0 --location=global
RUN npm install
COPY . .
ENV NODE_ENV=production
# Some custom processes
RUN npm run build:prod
FROM node:17-alpine
WORKDIR /app
COPY . ./
RUN npm install npm@8.5.0 --location=global
RUN npm install <-------------------------------------------- THE FAIL IS HERE
COPY --from=builder /app/dist ./
EXPOSE 3000
CMD npm run launch:production
这是一个错误:
Step 19/22 : RUN npm install
---> Running in b009e097d4ae
npm WARN deprecated crypto@1.0.1: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
> server@0.0.1 postinstall
> rimraf dist && npm run build
> server@0.0.1 prebuild
> rimraf dist
> server@0.0.1 build
> nest build
node_modules/@nestjs/common/index.d.ts:10:15 - error TS2307: Cannot find module './serializer' or its corresponding type declarations.
10 export * from './serializer';
~~~~~~~~~~~~~~
node_modules/@nestjs/common/index.d.ts:11:15 - error TS2307: Cannot find module './services' or its corresponding type declarations.
11 export * from './services';
~~~~~~~~~~~~
node_modules/@nestjs/common/index.d.ts:12:15 - error TS2307: Cannot find module './utils' or its corresponding type declarations.
12 export * from './utils';
~~~~~~~~~
node_modules/@nestjs/common/interfaces/nest-application-context-options.interface.d.ts:1:41 - error TS2307: Cannot find module '../services/logger.service' or its corresponding type declarations.
1 import { LoggerService, LogLevel } from '../services/logger.service';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/common/interfaces/nest-application-context.interface.d.ts:2:41 - error TS2307: Cannot find module '../services/logger.service' or its corresponding type declarations.
2 import { LoggerService, LogLevel } from '../services/logger.service';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/common/pipes/index.d.ts:3:15 - error TS2307: Cannot find module './parse-bool.pipe' or its corresponding type declarations.
3 export * from './parse-bool.pipe';
~~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/common/pipes/index.d.ts:4:15 - error TS2307: Cannot find module './parse-int.pipe' or its corresponding type declarations.
4 export * from './parse-int.pipe';
~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/common/pipes/index.d.ts:5:15 - error TS2307: Cannot find module './parse-float.pipe' or its corresponding type declarations.
5 export * from './parse-float.pipe';
~~~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/common/pipes/index.d.ts:6:15 - error TS2307: Cannot find module './parse-enum.pipe' or its corresponding type declarations.
6 export * from './parse-enum.pipe';
~~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/common/pipes/index.d.ts:7:15 - error TS2307: Cannot find module './parse-uuid.pipe' or its corresponding type declarations.
7 export * from './parse-uuid.pipe';
~~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/common/pipes/index.d.ts:8:15 - error TS2307: Cannot find module './validation.pipe' or its corresponding type declarations.
8 export * from './validation.pipe';
~~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/common/pipes/parse-array.pipe.d.ts:3:55 - error TS2307: Cannot find module './validation.pipe' or its corresponding type declarations.
3 import { ValidationPipe, ValidationPipeOptions } from './validation.pipe';
~~~~~~~~~~~~~~~~~~~
node_modules/@nestjs/core/injector/instance-loader.d.ts:1:10 - error TS2305: Module '"@nestjs/common"' has no exported member 'Logger'.
1 import { Logger } from '@nestjs/common';
~~~~~~
node_modules/@nestjs/core/nest-application-context.d.ts:1:35 - error TS2305: Module '"@nestjs/common"' has no exported member 'LoggerService'.
1 import { INestApplicationContext, LoggerService, LogLevel, ShutdownSignal } from '@nestjs/common';
~~~~~~~~~~~~~
node_modules/@nestjs/core/nest-application-context.d.ts:1:50 - error TS2305: Module '"@nestjs/common"' has no exported member 'LogLevel'.
1 import { INestApplicationContext, LoggerService, LogLevel, ShutdownSignal } from '@nestjs/common';
我试图强制运行npm卸载@nestjs/common && unsinstall @nestjs/common,而不作任何更改。我已经重新做了所有的步骤,缓存清除在gitlab等。
发布于 2022-10-13 18:53:06
如果不链接你的语言设置就很难做到。
这样你才能确定你有正确的..。
鸟巢图书馆..。
在您的libs / filled中有一个包含您的公共库的目录..。
+libs
-common
--src
---package1
---package2
---index.ts
在索引ts中,您要导出同一目录的各个模块成员.看上去像这样。
export * from './database/database.module';
export * from './database/abstract.repository';
export * from './database/abstract.schema';
export * from './rmq/rmq.service';
export * from './rmq/rmq.module';
export * from './auth/auth.module';
export * from './auth/jwt-auth.guard';
export * from './constants/ServicePorts';
现在,当您想要使用公共库时,您要这样做,如下所示。
import { RmqModule } from '@app/common';
import { Logger } from '@app/common'
https://stackoverflow.com/questions/72994616
复制相似问题