You have to try
npm install
and than after
npm run build
after this you just have to start npm run dev
Can’t migrate to ViteJS
I am working on a project running in Laravel Homestad, migrated from v8 to v9 following the official upgrade guide. (https://laravel.com/docs/9.x/upgrade#upgrade-9.0).
The project originally worked with laravel-mix and command npm run dev to run the webpack.mix.js configuration and if I try to run like this, it returns the following error:
>dev
> npm run development
> development
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
node:internal/modules/cjs/loader:936
throw error;
^
Error: Cannot find module '..'
Requirestack:
- /home/vagrant/code/intranet2022/node_modules/.bin/cross-env
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/vagrant/code/intranet2022/node_modules/.bin/cross-env:4:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/vagrant/code/intranet2022/node_modules/.bin/cross-env' ]
}
Now I am trying to upgrade the "webpack " bundler module to "vitejs" as required by the new version of laravel following the following guide: https://github.com/laravel/vite-plugin/blob/main/UPGRADE.md#migrating
But in the step npm install --save-dev vite laravel-vite-plugin, I get errors from NPM.
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=0.10.0 <7' },
npm WARN EBADENGINE current: { node: 'v16.16.0', npm: '8.11.0' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=4 <=9' },
npm WARN EBADENGINE current: { node: 'v16.16.0', npm: '8.11.0' }
npm WARN EBADENGINE }
npm ERR! code EPROTO
npm ERR! syscall symlink
npm ERR! path ../esbuild/bin/esbuild
npm ERR! dest /home/vagrant/code/intranet2022/node_modules/.bin/esbuild
npm ERR! wrong -71
npm ERR! EPROTO: protocol error, symlink '../esbuild/bin/esbuild' -> '/home/vagrant/code/intranet2022/node_modules/.bin/esbuild'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2022-07-28T09_27_27_280Z-debug-0.log
Previously made changes: Updated installed nodejs from v14 to v16.
Tests I have performed (with same consequences):
Test 1: rm -rf node_modules && npm cache clean -f && npm install
Test 2: rm package-lock.json && npm install
Test 3: Runned npm install from windows host cli.
Since you're updating to Vite you don't need Laravel Mix anymore so you can remove that from your package.json.
npm uninstall laravel-mix
And update your scripts section to use Vite instead of Laravel Mix.
"scripts": {
"dev": "vite",
"build": "vite build"
},
You also need the laravel-vite-plugin.
npm install laravel-vite-plugin
Or look at the latest Laravel application code to see what they have as dependencies and what you don't. And if you use Vue as well look at Breeze or Jetstream, they have Inertia with Vue that might help you further.
Please or to participate in this conversation.