LaravelDaily/Larastarters

Error: [vite]: Rollup failed to resolve import "lodash"

1MuneebUrRehman opened this issue · 4 comments

While running "php artisan larastarters:install" command and selecting option 2, followed by option 0. During the build, Vite failed to resolve the import "lodash" from "C:/laragon/www/test/resources/js/bootstrap.js".

Laravel v10.3.2 (PHP v8.1.10)

Steps to Reproduce

  1. Run composer require laraveldaily/larastarters --dev command in your Laravel project.
  2. Run php artisan larastarters:install command.
  3. Select option 2, followed by option 0.

Error Traceback

Error: [vite]: Rollup failed to resolve import "lodash" from "C:/laragon/www/test/resources/js/bootstrap.js".
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:///C:/laragon/www/test/node_modules/vite/dist/node/chunks/dep-ca21228b.js:44792:19)
    at onwarn (file:///C:/laragon/www/test/node_modules/vite/dist/node/chunks/dep-ca21228b.js:44562:13)
    at Object.onwarn (file:///C:/laragon/www/test/node_modules/rollup/dist/es/shared/node-entry.js:24950:13)
    at ModuleLoader.handleInvalidResolvedId (file:///C:/laragon/www/test/node_modules/rollup/dist/es/shared/node-entry.js:23632:26)
    at file:///C:/laragon/www/test/node_modules/rollup/dist/es/shared/node-entry.js:23592:26

image

image

Solution

npm install lodash
npm install && npm run dev

@PovilasKorop Can you look into this? Thanks

krekas commented

This issue is related to this pr laravel/ui#247 could you make a pr with a fix?

Sure, I can help you with that!

I have tested the changes locally and they appear to resolve the issue.

Hi @krekas!

I've just submitted a pull request to address the issue #124 and I was wondering if you could take a look at it and provide me with some feedback. I'd really appreciate it!

The link to the pull request is here. Let me know if you have any questions or if there's anything else I can do to help. Thanks a lot for your time!