Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lbriganti's avatar

Npm run build fails with vite - laravel 9

Hi, I installed a fresh new project with Laravel 9 that by default installs Vite, as you know. But I can't actually run npm run build, because it fails with this error code:

file:///var/www/html/{...}/node_modules/vite/bin/vite.js:7 await import('source-map-support').then((r) => r.default.install()) ^^^^^

SyntaxError: Unexpected reserved word at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18) at async link (internal/modules/esm/module_job.js:42:21)

That refers to a vite file. How can I resolve?

I'm running Laravel on Ubuntu 22 (LAMP stack), PHP 8. Thanks.

0 likes
4 replies
lbriganti's avatar
lbriganti
OP
Best Answer
Level 1

Nevermind, I updated node via nvm to version 16.16.0 and now all works well.

4 likes
thinkverse's avatar

@lbriganti If that fixed it, please mark your answer as the solution for other users who might have the same issue in the future.

1 like

Please or to participate in this conversation.