首页 > 解决方案 > 构建 docker 容器时反应应用程序错误

问题描述

错误:

    => ERROR [5/6] RUN npm install                                                                                                                        143.3s
    ------                                                                                                                                                        
    > [5/6] RUN npm install:                                                                                                                                     
    #9 143.0 npm notice                                                                                                                                           
    #9 143.0 npm notice New minor version of npm available! 7.15.1 -> 7.18.1                                                                                      
    #9 143.0 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.18.1>                                                                              
    #9 143.0 npm notice Run `npm install -g npm@7.18.1` to update!                                                                                                
    #9 143.0 npm notice 
    #9 143.0 npm ERR! code 254
    #9 143.0 npm ERR! git dep preparation failed
    #9 143.0 npm ERR! command /usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/root/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit
    #9 143.0 npm ERR! npm WARN using --force Recommended protections disabled.
    #9 143.0 npm ERR! npm WARN tarball tarball data for ethereumjs-abi@git+https://github.com/ProjectWyvern/ethereumjs-abi.git (null) seems to be corrupted. Trying again.
    #9 143.0 npm ERR! npm WARN tarball tarball data for ethereumjs-abi@git+https://github.com/ProjectWyvern/ethereumjs-abi.git (null) seems to be corrupted. Trying again.
    #9 143.0 npm ERR! npm WARN tarball tarball data for bignumber.js@git+https://github.com/frozeman/bignumber.js-nolookahead.git (null) seems to be corrupted. Trying again.
    #9 143.0 npm ERR! npm WARN tarball tarball data for bignumber.js@git+https://github.com/frozeman/bignumber.js-nolookahead.git (null) seems to be corrupted. Trying again.
    #9 143.0 npm ERR! npm ERR! code ENOENT
    #9 143.0 npm ERR! npm ERR! syscall spawn git
    #9 143.0 npm ERR! npm ERR! path git
    #9 143.0 npm ERR! npm ERR! errno -2
    #9 143.0 npm ERR! npm ERR! enoent spawn git ENOENT
    #9 143.0 npm ERR! npm ERR! enoent This is related to npm not being able to find a file.
    #9 143.0 npm ERR! npm ERR! enoent 
    #9 143.0 npm ERR! 
    #9 143.0 npm ERR! npm ERR! A complete log of this run can be found in:
    #9 143.0 npm ERR! npm ERR!     /root/.npm/_logs/2021-06-22T06_00_50_967Z-debug.log
    #9 143.1 
    #9 143.1 npm ERR! A complete log of this run can be found in:
    #9 143.1 npm ERR!     /root/.npm/_logs/2021-06-22T06_01_02_702Z-debug.log
    ------
    executor failed running [/bin/sh -c npm install]: exit code: 254

Dockerfile

    # pull the base image
    FROM node:alpine

    # set the working direction
    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 

    # add app
    COPY . ./

    # start app
    CMD ["npm", "start"]

我正在使用下面的命令来运行它。

docker build -t ps-container:dev .

嗨,我在将我的 react 应用程序 dockerizing 以进行本地开发时遇到问题。我已经分享了错误和 Dockerfile。请看看我在哪里做错了。

我关注了https://www.pluralsight.com/guides/using-react.js-with-docker文档,但仍然没有工作

请看一下。

标签: reactjsdocker

解决方案


推荐阅读