小编Doo*_*mel的帖子

PNPM 与独立 NextJS 构建链接

我正在尝试使用 NextJS 独立模式和 PNPM 创建生产 Dockerfile。

next.config.js我有输出配置:

  experimental: {
    outputStandalone: true,
    outputFileTracingRoot: path.join(__dirname, '../../'),
  },
Run Code Online (Sandbox Code Playgroud)

在 Dockerfile 中,我使用多阶段构建:

# BUILD STEP
FROM node:16.13-alpine as landing-builder
WORKDIR /dml-sdk

COPY ./pnpm-workspace.yaml .
COPY ./pnpm-lock.yaml .
COPY ./tsconfig.base.json .
COPY ./package.json .

COPY ./apps/landing ./apps/landing

RUN apk --no-cache add curl
RUN apk --no-cache add git
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
RUN pnpm config set store-dir .pnpm-store

RUN pnpm i
RUN pnpm build

# RUNNER STEP
FROM …
Run Code Online (Sandbox Code Playgroud)

node.js docker next.js pnpm

19
推荐指数
1
解决办法
2399
查看次数

如何在 MaterialUI 中扩展 OverridableComponent 接口

我正在尝试使用Container带有样式组件的组件,ContainerProps但是我无法传递component属于OverridableComponent接口的prop 。下面的代码给了我错误,告诉我我不能传递component财产。当我改变<Container/><MuiContainer/>它的工作原理。

MuiContainer有类型,OverridableComponent<ContainerTypeMap<{}, 'div'>>但我无法OverridableComponent从中导入@material-ui/core

我怎样才能使传递component财产成为可能?

import { Container as MuiContainer, ContainerProps } from '@material-ui/core';
import React from 'react';
import styled from 'styled-components';

const Container = styled(MuiContainer)<ContainerProps>``;

export const Test = () => {
  return (
    <>
      <Container maxWidth="lg" component="main">
        content
      </Container>
    </>
  );
};
Run Code Online (Sandbox Code Playgroud)

typescript reactjs material-ui styled-components

13
推荐指数
1
解决办法
591
查看次数

MacOS 请求 Node 父进程而不是子进程的权限

使用child_process模块,我尝试生成应该请求权限的进程,但 MacOS 请求父进程而不是生成的子进程的权限。

例如,当我在终端中运行下面的代码时,MacOS 将请求“Terminal.app”而不是子进程的权限。exec/execFile 函数也会发生同样的情况。

现实生活中的示例是从 Google Chrome 中删除麦克风权限,在终端中运行下面的代码并转到 google meet。MacOS 将请求 Terminal.app 的麦克风权限,而不是 Google Chrome。

是否可以使用 child_process 模块并使 MacOS 请求子进程的权限?

const { spawn } = require("child_process");
const APP_PATH = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome';
spawn(APP_PATH, [], {
  detached: true,
  stdio: "ignore",
}).unref();
Run Code Online (Sandbox Code Playgroud)

javascript macos node.js

6
推荐指数
1
解决办法
628
查看次数

尝试使用 export * 语法时 ESLint、React/TS 的问题

是否可以export * from './X'在 react/typescript 中使用绝对导入路径和 eslint?我想在 components 文件夹中有一个 index.ts 文件,它可以导出其他所有内容,但是当我尝试这样做时,eslint 给了我奇怪的错误。

我目前的结构是这样的:

src/components/Example1/Example1.tsx

import React from 'react';

export type Props = {};
export const Example1 = (props: Props) => <div></div>
Run Code Online (Sandbox Code Playgroud)

src/components/Example1/index.ts

export * from './Example1';
Run Code Online (Sandbox Code Playgroud)

src/components/index.ts

export * from './Example1';
Run Code Online (Sandbox Code Playgroud)

这两个index文件都给我错误: 0:0 error Parsing error: Cannot read property 'name' of undefined

此外,当我尝试components/index使用绝对路径从文件中导入任何内容时,import { Example1 } from 'components';出现错误:

1:43  error  Parse errors in imported module 'components': Cannot read property 'name' of undefined …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs eslint

5
推荐指数
1
解决办法
4277
查看次数

GitLab 没有在作业中正确传播退出代码

.gitlab-ci.yml为使用pnpm. 工作清单是:

deploy_npm:
  image: node:16.14.0-bullseye-slim
  stage: deploy
  before_script:
    - npm install -g pnpm@6.32.2
    - pnpm build
  script:
    - pnpm publish
    - echo $?
Run Code Online (Sandbox Code Playgroud)

问题是,当我没有使用.npmrc正确的身份验证令牌创建文件时,并且收到“未经授权”错误,作业状态仍然成功,因为退出状态为0。如果我在本地环境中运行相同的命令,那么退出状态将为1.

npm notice Publishing to ****************
npm ERR! code E401
npm ERR! 401 Unauthorized - PUT *******************
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-07-08T13_22_44_392Z-debug-0.log
$ echo $?
0
Cleaning up project directory and file based variables
00:01
Job succeeded …
Run Code Online (Sandbox Code Playgroud)

node.js npm gitlab

5
推荐指数
1
解决办法
847
查看次数