【问题标题】:Command not found after running docker build运行 docker build 后找不到命令
【发布时间】:2023-02-04 05:42:37
【问题描述】:

我在跑 docker build --build-arg npm_token=//NPM TOKEN HERE// -t test .

并且构建失败并显示错误消息 error Command "dotenv" not found 即使 dotenv nom 包包含在 package.json 和 yarn.lock 文件中。这是我的泊坞窗文件:

# image has Cypress npm module installed globally in /root/.npm/node_modules
# and Cypress binary cached in /root/.cache/Cypress folder
FROM cypress/included:9.7.0

WORKDIR /usr/src/app

# Set up NPM token to access private GitHub packages
ARG npm_token
ENV NPM_TOKEN=$npm_token
COPY .npmrc ./
RUN npm config set //npm.pkg.github.com/:_authToken $NPM_TOKEN

COPY config cypress .env package.json cypress.json yarn.lock  tsconfig.json ./

RUN yarn \
    dotenv -- node e2e-tests.js

有谁知道为什么会这样?

【问题讨论】:

    标签: docker npm dotenv


    【解决方案1】:

    你应该安装dotenv-cli来运行.env命令:

    yarn add dotenv-cli
    

    【讨论】:

    • 你好,谢谢你的回复。我在 package.json 和 yarn.lock 文件中也有 dotenv-cli
    • 尝试全局安装
    猜你喜欢
    • 2018-05-20
    • 2019-01-17
    • 2017-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    • 2021-01-08
    相关资源
    最近更新 更多