9

Recently, I got unexpected problem when deploying my Ruby on Rails app to Heroku:

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

To be honest, I do not have any idea because I did not touch any javascript code at all, does anyone encounter this error and resolved it?

Here is the full logs: https://gist.github.com/johnvmo/b3340f541cf32cb0c15ecbffc1aca6f9

I am very appreciated if someone can help.

Chau Giang
  • 1,414
  • 11
  • 19
  • I reslove it using the second answer in this [link](https://stackoverflow.com/questions/62246824/error-err-package-path-not-exported-no-exports-main-resolved-in-app-node-m) ```I had the similar problem. npm install @babel/helper-compilation-targets --save-dev solved this situation``` – realsarm Aug 01 '20 at 15:30

3 Answers3

8

Ran into the same error and found this:

Solution

This is a regression in Node.js. If you hit this issue from search engines, please choose one of the following solutions

  1. update @babel deps to v7.8.7

  2. use Node < 13.9

  3. wait until nodejs/node#32107 is fixed! (Probably in the next Node.js patch release).

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

DoubleMalt
  • 1,263
  • 12
  • 17
  • update babel deps to v7.8.7 => it will very complicated, for example I am using plugin uppy/dashboard that is using preact v8 and preact v8 currently uses @babel 7.0 – Chau Giang Jun 16 '20 at 12:07
1

I have simple solution just downgrade Nodejs version to v10 LTS or 11. For example in my Raisl app, my Dockerfile look like this:

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"]
Chau Giang
  • 1,414
  • 11
  • 19
0

Based on @DoubleMalt answer, I downgraded Node to v13.8.0, it worked. It's an old project.

However, for the current Nuxt project, it hits an error:

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

but the project runs fine so far.

Asil
  • 11
  • 2
  • 1
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. – StevenSiebert Sep 02 '21 at 05:13