Production Build [rollup-plugin-dynamic-import-variables] Unexpected token

Hello Guys!

I’m facing one issue on production build only on netlify. If I execute production build in my local it’s works perfect.

Here is the error screenshot

Please help me if anyone have solution of this error

Hi there, glad you found us :wave: before we can help you, we need a little more information on the issues you are facing.

First, have you looked through this resource? It is a compilation of all of our build and deploy resources. This is a good starting point.

If you have worked through those guides and are still encountering issues please share the following information:

  • the name of your build instance: “example-jones.netlify.com
  • what you have already tried
  • your full build log
  • your build settings

Hi Hillary,

Thanks for the quick response. Actually, our config.js file only has just one configuration.

and error is causing the line where we simply fetch the .env variables like: process.env.<VARIABLE_NAME>

Please look at the below screenshot.

The build works locally.

Hi Hillary,

my last e-mail was rejected as it did not like the log in the e-mail.

The build log is attached
can you not see the log info?

Please help as this build is urgent.

Thanks

(Attachment log.txt is missing)

Hi Hillary,

I keep getting

Unfortunately some attachments in your email message to [“incoming+584265186c1ae0107fd3e30361f5a759@netlify.discoursemail.com”] (titled Re: [Netlify Support Forums] [Support] Production Build [rollup-plugin-dynamic-import-variables] Unexpected token) were rejected.

We only have 1 project we are trying to deploy.
it works on local but not in production.

Can you please view the log staging.telemedic.health

Thanks

Hey @Tom_Curtain

The error is coming one of the source files in your site as listed in the screenshot (please note providing text as opposed to images makes it much easier to provide assistance.)

Have you check the syntax of the file? If you run npm run build locally, does the error occur?

Can you share the repository?

Thanks @coelmay!

but there are no any error on npm run build in locally

Error is showing like not process the .env variables.

Let me share here config.js file for more clarification

const getDevPort = (protocol: string) =>
  protocol === "https:" ? "5001" : "5000";

export default {
  dev: process.env.NODE_ENV === "development",
  title: "TeleMedic",
  get apiUrl() {
    const { protocol, hostname } = window.location;

    // match localhost
    if (hostname === "localhost")
      return `${protocol}//${hostname}:${getDevPort(protocol)}`;

    // match ip address
    if (hostname.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/))
      return `${protocol}//${hostname}:${getDevPort(protocol)}`;

    // match *.telemedic.health
    if (hostname.match(/^(.+)\..+\..+$/)) return `${protocol}//api-${hostname}`;

    // default, add api. to root
    return `${protocol}//api.${hostname}`;
  },
  endpointGraph: "/",
  endpointFaye: "/faye",
  sentryDsn: process.env.SENTRY_DSN,
  sentryEnvironment: process.env.SENTRY_ENVIRONMENT || "local",
  sentrySampleRate: process.env.NODE_ENV !== "development" ? 0.5 : 1.0,
};

Hey there, @Tom_Curtain :wave:

Thanks so much for your patience here. Can you try upgrading to vite 3? We wonder if using the latest version will address the obstacle you are encountering.

1 Like