首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用@ nestjs / building在远程码头上创建nestjs

使用@ nestjs / building在远程码头上创建nestjs
EN

Stack Overflow用户
提问于 2022-07-15 13:17:08
回答 1查看 43关注 0票数 0

我有一个NestJs项目,是建立在码头在gitlab CI。

在本地,dockerfile构建得非常好,包括:

代码语言:javascript
运行
复制
docker build -t server .

但是在gitbal CI中,使用相同的对接器和相同的命令,它就会崩溃。尤其是@nestjs/common。)我了解到码头在每个环境中都是以同样的方式工作的。)

这是我的Dockerfile:

代码语言:javascript
运行
复制
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

这是一个错误:

代码语言:javascript
运行
复制
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等。

EN

回答 1

Stack Overflow用户

发布于 2022-10-13 18:53:06

如果不链接你的语言设置就很难做到。

这样你才能确定你有正确的..。

鸟巢图书馆..。

在您的libs / filled中有一个包含您的公共库的目录..。

代码语言:javascript
运行
复制
+libs
 -common
   --src
     ---package1
     ---package2
     ---index.ts

在索引ts中,您要导出同一目录的各个模块成员.看上去像这样。

代码语言:javascript
运行
复制
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';

现在,当您想要使用公共库时,您要这样做,如下所示。

代码语言:javascript
运行
复制
import { RmqModule } from '@app/common';
import { Logger } from '@app/common'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72994616

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档