Cannot build on render but locally can [vite] react

Try to deploy to the render but always got following error:

Could not resolve ‘…/component/ComponentToPrint’ from src/page/luRegistration.jsx

May 11 01:58:56 PM  36 packages are looking for funding
May 11 01:58:56 PM    run `npm fund` for details
May 11 01:58:56 PM  
May 11 01:58:56 PM  found 1 high severity vulnerability
May 11 01:58:56 PM    run `npm audit fix` to fix them, or `npm audit` for details
May 11 01:58:57 PM  
May 11 01:58:57 PM  > array-wms@0.0.0 build /opt/render/project/src
May 11 01:58:57 PM  > vite build
May 11 01:58:57 PM  
May 11 01:58:57 PM  vite v2.9.13 building for production...
May 11 01:58:57 PM  transforming...
May 11 01:58:58 PM  '@popperjs/core' is imported by @popperjs/core?commonjs-external, but could not be resolved – treating it as an external dependency
May 11 01:59:00 PM  ✓ 67 modules transformed.
May 11 01:59:00 PM  Could not resolve '../component/ComponentToPrint' from src/page/luRegistration.jsx
May 11 01:59:00 PM  error during build:
May 11 01:59:00 PM  Error: Could not resolve '../component/ComponentToPrint' from src/page/luRegistration.jsx
May 11 01:59:00 PM      at error (/opt/render/project/src/node_modules/rollup/dist/shared/rollup.js:198:30)
May 11 01:59:00 PM      at ModuleLoader.handleResolveId (/opt/render/project/src/node_modules/rollup/dist/shared/rollup.js:22508:24)
May 11 01:59:00 PM      at /opt/render/project/src/node_modules/rollup/dist/shared/rollup.js:22471:26
May 11 01:59:00 PM  npm ERR! code ELIFECYCLE
May 11 01:59:00 PM  npm ERR! errno 1
May 11 01:59:00 PM  npm ERR! array-wms@0.0.0 build: `vite build`
May 11 01:59:00 PM  npm ERR! Exit status 1
May 11 01:59:00 PM  npm ERR!
May 11 01:59:00 PM  npm ERR! Failed at the array-wms@0.0.0 build script.
May 11 01:59:00 PM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
May 11 01:59:00 PM  
May 11 01:59:00 PM  npm ERR! A complete log of this run can be found in:
May 11 01:59:00 PM  npm ERR!     /opt/render/.cache/_logs/2023-05-11T06_59_00_718Z-debug.log
May 11 01:59:00 PM  ==> Build failed 😞

is your build working in your local environment?

Yes it working fine.
It can build to get dist folder and able to use npm run preview to see the app.

I see that you’ve already initiated a support ticket with us. To avoid any confusion or duplicate efforts, let’s continue the conversation there.

Regards.
Jérémy, Render Support

Hello! I’m having the same problem here. My build works locally, however I get the same error:

Could not resolve “…/pricing/pricing” from “src/components/main-container/MainContainer.jsx”

I currently have replaced the problematic component with just this to check whether it was my fault or not:

const Pricing = () => {
  return (
    <>
      <h2>TEST</h2>
    </>
  );
};

export default Pricing;

But I’m still getting the following error:

Jun 7 01:31:55 PM  > first-project@0.0.0 build /opt/render/project/src
Jun 7 01:31:55 PM  > vite build
Jun 7 01:31:55 PM  
Jun 7 01:31:56 PM  vite v4.3.9 building for production...
Jun 7 01:31:56 PM  transforming...
Jun 7 01:31:56 PM  ✓ 19 modules transformed.
Jun 7 01:31:56 PM  ✓ built in 580ms
Jun 7 01:31:56 PM  Could not resolve "../pricing/pricing" from "src/components/main-container/MainContainer.jsx"
Jun 7 01:31:56 PM  file: /opt/render/project/src/src/components/main-container/MainContainer.jsx
Jun 7 01:31:56 PM  error during build:
Jun 7 01:31:56 PM  RollupError: Could not resolve "../pricing/pricing" from "src/components/main-container/MainContainer.jsx"
Jun 7 01:31:56 PM      at error (file:///opt/render/project/src/node_modules/rollup/dist/es/shared/node-entry.js:2130:30)
Jun 7 01:31:56 PM      at ModuleLoader.handleInvalidResolvedId (file:///opt/render/project/src/node_modules/rollup/dist/es/shared/node-entry.js:24041:24)
Jun 7 01:31:56 PM      at file:///opt/render/project/src/node_modules/rollup/dist/es/shared/node-entry.js:24003:26
Jun 7 01:31:56 PM  npm ERR! code ELIFECYCLE
Jun 7 01:31:56 PM  npm ERR! errno 1
Jun 7 01:31:56 PM  npm ERR! first-project@0.0.0 build: `vite build`
Jun 7 01:31:56 PM  npm ERR! Exit status 1
Jun 7 01:31:56 PM  npm ERR!
Jun 7 01:31:56 PM  npm ERR! Failed at the first-project@0.0.0 build script.
Jun 7 01:31:56 PM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Jun 7 01:31:56 PM  
Jun 7 01:31:56 PM  npm ERR! A complete log of this run can be found in:
Jun 7 01:31:56 PM  npm ERR!     /opt/render/.cache/_logs/2023-06-07T11_31_56_732Z-debug.log
Jun 7 01:31:56 PM  ==> Build failed 😞

Thanks!

I fix this issue already.
some reason i gotta move this ComponentToPrint file in to the same folder that I import this file.
it’s not realy nice way but it’s working.

Thank you!

I just created a new component from scratch, Billing.jsx instead of the problematic Pricing.jsx and basically copy-pasted the old code. Now it works! Maybe the original file was somehow corrupt?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.