ruby 运行rails -server时出错,接收错误:yarn:error:无此选项:--诚信

xcitsw88  于 2023-08-04  发布在  Ruby
关注(0)|答案(2)|浏览(77)

我正在使用Rails 6.0.3.4和Ruby 2.7.1,当我运行rails -s时,我在终端中得到以下错误:

Usage: yarn [options]

yarn: error: no such option: --integrity

========================================
  Your Yarn packages are out of date!
  Please run `yarn install --check-files` to update.
========================================

To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).

字符串
当我运行yarn install --check-files时,我收到以下错误:

yarn: error: no such option: --check-files


我在webpacker.yml中将check_yarn_integrity设置为false。

bbmckpt7

bbmckpt71#

尝试使用npm install --global yarn

v1uwarro

v1uwarro2#

你确实应该使用npm来安装yarn,但你应该在Docker内部安装。

RUN apt-get update && apt-get install -y curl gnupg2 && \
    curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
    apt-get install -y nodejs && \
    npm install -g yarn

COPY package.json yarn.lock ./
RUN yarn install --check-files

字符串
下面是我的Dockerfile的样子:

FROM ruby:2.7.2

# Set the working directory in the container
WORKDIR /app

RUN apt-get update && apt-get install -y curl gnupg2 && \
    curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
    apt-get install -y nodejs && \
    npm install -g yarn

COPY package.json yarn.lock ./
RUN yarn install --check-files

# Copy the Gemfile and Gemfile.lock to the container
COPY Gemfile Gemfile.lock ./

# Install dependencies
RUN bundle install

# Copy the rest of the application to the container
COPY . .

# Set up environment variables
ENV DATABASE_URL=postgresql://postgres:password@db:5432/app_development

# Start the Rails server
CMD ["rails", "server", "-b", "0.0.0.0"]


然后运行docker-compose builddocker-compose up。应该能用

相关问题