1

after installing react with inertia js on laravel 8. While running "npm run dev" getting the following error

PS D:\Projects\Inertiajs with react and laravel\project> npm run dev

> @ dev D:\Projects\Inertiajs with react and laravel\project
> npm run development


> @ development D:\Projects\Inertiajs with react and laravel\project
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js

98% after emitting SizeLimitsPlugin

 ERROR  Failed to compile with 4 errors                                                                                                             6:35:46 PM

TypeError: Cannot read property 'startsWith' of undefined
    at isRelative (D:\Projects\Inertiajs with react and laravel\project\node_modules\friendly-errors-webpack-plugin\src\formatters\moduleNotFound.js:5:17)

1 Answer 1

6

I ran into this same problem trying to install inertia/react on top of laravel 8. I fixed the error by adding the Pages folder to resources/js in the laravel project. It happens because following the inertia doc, you reference

resolveComponent={name => require(./Pages/${name}).default}

inside the app.js render function but that folder doesn't exist until you create it. Best of luck!

Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately, I'm running in the same problem, but creating resources/js/Pages didn't fix it. Is this where you created that folder?
Sorry, found it. I had @/Pages/${name} instead of ./Pages/${name}
If this worked, mind giving me an upvote? I'm new to stackoverflow :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.