首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >跳过@testing运行npm安装时的库

跳过@testing运行npm安装时的库
EN

Stack Overflow用户
提问于 2022-02-21 14:32:26
回答 1查看 147关注 0票数 0

有什么办法可以通过运行@testing-library*来跳过安装npm install,我有码头容器,而我的package-lock.json有4000多行。是否可以跳过安装@testing-library*

代码语言:javascript
复制
FROM node:17.5

# set working directory
WORKDIR /app

# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH

# install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install --silent
...

package.json

代码语言:javascript
复制
{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.2",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "node-sass": "^7.0.1",
    "react": "^17.0.2",
    "react-copy-to-clipboard": "^5.0.4",
    "react-dom": "^17.0.2",
    "react-router-dom": "^5.2.0",
    "react-scripts": "5.0.0",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

我想跳过安装

代码语言:javascript
复制
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-21 15:12:48

您可以做的是将您的测试依赖项移动到devDependencies中的package.json中,如下所示:

代码语言:javascript
复制
devDependencies: {
    "@testing-library/jest-dom": "^5.16.2",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0"
}

在码头安装时,运行npm install --production而不是npm install

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71208061

复制
相关文章

相似问题

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