node_modulesを消してnpm install をやり直したらnpm run devができなくなった件
Laravel + vue.jsで開発中に新しいプラグインを試していた。
importできないので解決方法を探していたらnode_modulesを消してnpm installをやり直すとできるらしい。
素直に実行した後npm run devを実行したところ
WARNING in ./node_modules/laravel-mix/src/VueVersion.js 30:35-67 Critical dependency: the request of a dependency is an expression WARNING in ./node_modules/laravel-mix/src/components/Vue.js 157:34-77 Critical dependency: the request of a dependency is an expression ERROR in ./node_modules/clean-css/lib/options/format.js 1:22-39 Module not found: Error: Can't resolve 'os' in '/Applications/MAMP/htdocs/attract_customer/node_modules/clean-css/lib/options' BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it. If you want to include a polyfill, you need to: - add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }' - install 'os-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "os": false } (中略) webpack compiled with 33 errors and 2 warnings
33個ものエラーとワーニングが。。。
webpack.mix.jsに
mix.webpackConfig({ resolve : { fallback : { "path" : false, "os" : false, "constants": false, "stream": false, "https": false, "http": false, "fs": false, } } })
を追加したところエラーは消えてくれた。
なお今まで表示できていたvueのcomponentは相変わらず表示できない模様。