Swalih VM Bazar
Swalih VM Bazar

Reputation: 66

Getting the following error Cannot read property 'startsWith' of undefined

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)

Upvotes: 1

Views: 2095

Answers (1)

Kyle
Kyle

Reputation: 76

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!

Upvotes: 6

Related Questions