-2

I am trying to build age viewer (go) locally but it is giving an error related to react-router after running:

wails dev

The following error is printed:

vite v3.2.5 building for production...
transforming...
✓ 7 modules transformed.

[vite]: Rollup failed to resolve import "react-router-dom" from "src/App.jsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:
Error: [vite]: Rollup failed to resolve import "react-router-dom" from "src/App.jsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
    at onRollupWarning (file:///home/postgres/pg/age_viewer/age/age-viewer/frontend/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:45832:19)
    at onwarn (file:///home/postgres/pg/age_viewer/age/age-viewer/frontend/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:45603:13)
    at Object.onwarn (file:///home/postgres/pg/age_viewer/age/age-viewer/frontend/node_modules/rollup/dist/es/shared/rollup.js:23263:13)
    at ModuleLoader.handleResolveId (file:///home/postgres/pg/age_viewer/age/age-viewer/frontend/node_modules/rollup/dist/es/shared/rollup.js:22158:26)
    at file:///home/postgres/pg/age_viewer/age/age-viewer/frontend/node_modules/rollup/dist/es/shared/rollup.js:22119:26
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  ERROR   exit status 1

I think there is some issue with package.json file perhaps. Any help is appreciated!

Edit

I have solved the issue. The package was missing in package.json file due to some reason.

han
  • 74
  • 7

6 Answers6

0

npm install react-router-dom@6 <--this should take care of required package.

0

Yes I think one of the desired package is missing. You can solve this error by first installing node if you have not already installed and than using the following command to install the desired package npm install react-router-dom.

0

it seems like react router dom dependency is missing. which is required to work properly with Age Viewer (Go).You can install the required dependency by running the command.

npm i react-router-dom

If you still have an issue of versions. To install a specific version you can run this commad.

npm install react-router-dom@5.3.0
0

I think the error you are encountering is due to the Rollup failing to resolve the import statement in your App.jsx. First make sure you have React-router-dom installed and is at the coorect version

npm install react-router-dom

OR

npm install react-router-dom@6

Verify the package is installed correctly in package.json then see if the import statement is correct in your App.jsx file

import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';

I hope this fixes your problem.

0

try wails doctor first to check the installation of wails then run set then env of wails. after that check you have npm version of 14.8 or higher

0

So to ensure Age Viewer functions correctly, you need to install the required dependency using the npm install react-router-dom. As it seems the react-router-dom module is missing or not properly configured.

This should solve the problem, most probably.