【问题标题】:Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in@babel/helper-compilation-targets/package.json错误 [ERR_PACKAGE_PATH_NOT_EXPORTED]:在@babel/helper-compilation-targets/package.json 中没有解决“导出”主要问题
【发布时间】:2020-09-16 18:36:29
【问题描述】:

最近,我在部署 Ruby on Rails 应用程序时遇到了意想不到的问题 到 Heroku:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in node_modules/@babel/helper-compilation-targets/package.json

说实话,我没有任何想法,因为我根本没有接触任何javascript代码,有人遇到这个错误并解决了吗?

这是完整的日志: https://gist.github.com/johnvmo/b3340f541cf32cb0c15ecbffc1aca6f9

如果有人可以提供帮助,我将不胜感激。

【问题讨论】:

  • 我很喜欢这个linkI had the similar problem. npm install @babel/helper-compilation-targets --save-dev solved this situation中的第二个答案

标签: javascript heroku babeljs


【解决方案1】:

遇到同样的错误,发现这个:

解决方案

这是 Node.js 中的回归。如果您从搜索引擎中遇到此问题,请选择以下解决方案之一

  1. 将@babel deps 更新到 v7.8.7

  2. 使用节点

  3. 等到 nodejs/node#32107 修复! (可能在下一个 Node.js 补丁版本中)。

https://github.com/babel/babel/issues/11216

【讨论】:

  • 将 babel deps 更新到 v7.8.7 => 这将非常复杂,例如我正在使用使用 preact v8 的插件 uppy/dashboard,而 preact v8 当前使用 @babel 7.0
【解决方案2】:

我有一个简单的解决方案,只需将 Nodejs 版本降级到 v10 LTS 或 11。例如,在我的 Raisl 应用程序中,我的 Dockerfile 如下所示:

FROM ruby:2.7.1

ARG DEBIAN_FRONTEND=noninteractive
ENV RAILS_ENV=production
ENV RAILS_SERVE_STATIC_FILES=true
ENV RAILS_LOG_TO_STDOUT=true
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
    apt-get update && \
    apt-get install -qq -y nodejs yarn vim
#RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends nodejs
COPY Gemfile* /usr/src/app/
WORKDIR /usr/src/app
RUN bundle config --global frozen 1
RUN bundle config set without 'development test'
RUN bundle install 
#RUN yarn install --prod
COPY . /usr/src/app/
# RUN bundle exec rake assets:precompile

CMD ["bin/rails", "s", "-b", "0.0.0.0"]

【讨论】:

    【解决方案3】:

    根据@DoubleMalt 的回答,我将 Node 降级到 v13.8.0,它可以工作。这是一个老项目。

    但是,对于当前的 Nuxt 项目,它遇到了一个错误:

    ExperimentalWarning: Package name self resolution is an experimental feature. This feature could change at any time
    

    但项目目前运行良好。

    【讨论】:

    • 这并不能真正回答问题。如果您有其他问题,可以点击 进行提问。要在此问题有新答案时收到通知,您可以follow this question。一旦你有足够的reputation,你也可以add a bounty 来引起更多的关注这个问题。
    猜你喜欢
    • 2020-09-26
    • 1970-01-01
    • 2021-12-04
    • 2020-07-20
    • 2021-11-10
    • 1970-01-01
    • 2021-12-13
    • 1970-01-01
    • 2022-06-17
    相关资源
    最近更新 更多