TypeError:(0,_schemaUtils.default)不是一个函数 [英] TypeError: (0 , _schemaUtils.default) is not a function

查看:352
本文介绍了TypeError:(0,_schemaUtils.default)不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 create-react-app 创建的简单React应用,该应用在localhost上运行良好.我现在正在尝试对应用程序进行Dockerify.这是我的package.json:

I have a simple React app created with create-react-app that runs fine on localhost. I'm now trying to Dockerify the app. Here's my package.json:

{
  "name": "yeet",
  "version": "0.1.0",
  "engines": {
    "node": "12.x"
  },
  "scripts": {
    "client": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "start": "node server.js",
    "production": "npm run build && npm run start"
  },
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "axios": "^0.21.0",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "express-session": "^1.17.1",
    "mongoose": "^5.10.13",
    "mysql": "^2.18.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.0",
    "web-vitals": "^0.2.4"
  },
  "devDependencies": {
    "babel-core": "*",
    "babel-loader": "*",
    "babel-preset-es2015": "*",
    "babel-preset-react": "*",
    "babel-preset-stage-0": "*"
  },
  "babel": {
    "presets": [
      "@babel/env",
      "@babel/react",
      "babel-preset-stage-0"
    ],
    "env": {
      "start": {
        "presets": [
          "@babel/env",
          "@babel/react",
          "babel-preset-stage-0"
        ]
      }
    }
  }
}

这是我的Dockerfile:

And here's my Dockerfile:

# Specify base image
FROM node:12.19.0-alpine3.10

# Specify app location in host
WORKDIR /app

# Copy the dependency list
COPY package.json ./

# Install app dependencies
RUN npm install

# Copy app code to host
COPY . .

# Open specified port
EXPOSE 3000:3000

# Start the app
CMD ["npm", "run", "production"]

我使用以下图像构建图像:

I build the image with:

docker build --tag yeet .

然后我将图像作为容器运行:

Then I run the image as a container with:

docker run --publish 3000:3000 yeet

抛出:

$ docker run-发布3000:3000

$ docker run --publish 3000:3000 yeet

yeet@0.1.0生产/appnpm运行构建&&npm运行开始

yeet@0.1.0 production /app npm run build && npm run start

yeet@0.1.0构建/app反应脚本构建

yeet@0.1.0 build /app react-scripts build

/app/node_modules/eslint-webpack-plugin/dist/options.js:62(0,_schemaUtils.default)(_ options.default,options,{^

/app/node_modules/eslint-webpack-plugin/dist/options.js:62 (0, _schemaUtils.default)(_options.default, options, { ^

TypeError:(0,_schemaUtils.default)不是一个函数在getOptions(/app/node_modules/eslint-webpack-plugin/dist/options.js:62:28)在新的ESLintWebpackPlugin(/app/node_modules/eslint-webpack-plugin/dist/index.js:30:44)在module.exports(/app/node_modules/react-scripts/config/webpack.config.js:749:7)在对象.(/app/node_modules/react-scripts/scripts/build.js:67:16)在Module._compile(internal/modules/cjs/loader.js:1015:30)在Object.Module._extensions..js(内部/模块/cjs/loader.js:1035:10)在Module.load(internal/modules/cjs/loader.js:879:32)在Function.Module._load(内部/模块/cjs/loader.js:724:14)在Function.executeUserEntryPoint [作为runMain](内部/模块/run_main.js:60:12)在internal/main/run_main_module.js:17:47 npm ERR!代码ELIFECYCLE npm ERR!errno 1 npm错误!yeet@0.1.0构建:反应脚本构建npm ERR!退出状态1 npm ERR!npm ERR!在yeet@0.1.0处失败构建脚本.npm ERR!npm可能不是问题.那里可能是上面的其他日志记录输出.

TypeError: (0 , _schemaUtils.default) is not a function at getOptions (/app/node_modules/eslint-webpack-plugin/dist/options.js:62:28) at new ESLintWebpackPlugin (/app/node_modules/eslint-webpack-plugin/dist/index.js:30:44) at module.exports (/app/node_modules/react-scripts/config/webpack.config.js:749:7) at Object. (/app/node_modules/react-scripts/scripts/build.js:67:16) at Module._compile (internal/modules/cjs/loader.js:1015:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10) at Module.load (internal/modules/cjs/loader.js:879:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) at internal/main/run_main_module.js:17:47 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! yeet@0.1.0 build: react-scripts build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the yeet@0.1.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR!此运行的完整日志可以在以下位置找到:npm ERR!
/root/.npm/_logs/2020-11-07T12_47_03_927Z-debug.log npm错误!代码ELIFECYCLE npm ERR!errno 1 npm错误!yeet@0.1.0 production: npm run build&&npm运行开始 npm错误!退出状态1 npm ERR!npm ERR!在yeet@0.1.0生产脚本上失败.npm ERR!这是npm可能不是问题.可能还有其他日志记录上面的输出.

npm ERR! A complete log of this run can be found in: npm ERR!
/root/.npm/_logs/2020-11-07T12_47_03_927Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! yeet@0.1.0 production: npm run build && npm run start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the yeet@0.1.0 production script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR!此运行的完整日志可以在以下位置找到:npm ERR!
/root/.npm/_logs/2020-11-07T12_47_03_923Z-debug.log

npm ERR! A complete log of this run can be found in: npm ERR!
/root/.npm/_logs/2020-11-07T12_47_03_923Z-debug.log

有人看到我在做什么错吗?任何指针都将非常有帮助!

Does anyone see what I'm doing wrong? Any pointers would be super helpful!

推荐答案

我确实遇到了同样的问题.我不确定删除或降级库是否在本地运行的其他解决方案.

I did have the same problem. I'm not sure about other solutions with removing or downgrading libraries if it runs localy.

要在这里解决,我跑了

docker container prune
docker image prune

在开始构建之前,请确保我的码头工人是干净的.

to be sure that my docker is clean before starting building.

如果没有成功,您可以尝试删除 yarn.lock package-lock.json .

If no success you can try to delete yarn.lock or package-lock.json.

如果可以帮助其他人,则我的文件是

If it can help others, my files are

.dockerignore

.dockerignore

.git
.gitignore
node_modules
build

Dockerfile.dev

Dockerfile.dev

FROM node:alpine

WORKDIR /app

COPY package.json /app

RUN yarn install

COPY . .

CMD ["yarn", "start"]

docker-compose.dev.yml

docker-compose.dev.yml

version: "3.8"
services:
  print:
    stdin_open: true
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - "3000:3000"
    volumes:
      - ".:/app"
      - "/app/node_modules"

Dockerfile.prod

Dockerfile.prod

FROM node:alpine as build

WORKDIR /app

COPY package.json /app

RUN yarn install

COPY . /app

RUN yarn run build

FROM nginx:stable-alpine
COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/build /usr/share/nginx/html

docker-compose.prod.yml

docker-compose.prod.yml

version: "3.8"
services:
  print:
    stdin_open: true
    build:
      context: .
      dockerfile: Dockerfile.prod
    ports:
      - "80:80"

nginx.conf

nginx.conf

server {  
  listen 80;
  server_name frontend;
  location / {
    root /usr/share/nginx/html;
    index index.html;
    try_files $uri /index.html;
  }
}

要运行

docker-compose.exe -f .\docker-compose.yml up --build

这篇关于TypeError:(0,_schemaUtils.default)不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆