Unable to Install #vitejs/plugin-vue inside Laravel project - laravel

I created a fresh Laravel project. And to use Vue JS I tried installing this package,
#vitejs/plugin-vue
But this throws me a set of errors,
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: #vitejs/plugin-vue#3.0.0
npm ERR! Found: vite#2.9.14
npm ERR! node_modules/vite
npm ERR! dev vite#"^2.9.11" from the root project
npm ERR! peer vite#"^2.9.9" from laravel-vite-plugin#0.4.0
npm ERR! node_modules/laravel-vite-plugin
npm ERR! dev laravel-vite-plugin#"^0.4.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vite#"^3.0.0" from #vitejs/plugin-vue#3.0.0
npm ERR! node_modules/#vitejs/plugin-vue
npm ERR! #vitejs/plugin-vue#"^3.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: vite#3.0.0
npm ERR! node_modules/vite
npm ERR! peer vite#"^3.0.0" from #vitejs/plugin-vue#3.0.0
npm ERR! node_modules/#vitejs/plugin-vue
npm ERR! #vitejs/plugin-vue#"^3.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I followed these steps,
1.laravel new {proj_name}.
2. npm install vue#next.
3. npm install.
4. After that I created a vue file and imported into app.js (resources/js/app.js).
5. I went to the blade file and cleared all -> hit `!` for emmet snippet, created a div with id #app, and add
#vite('resources/js/app.js').
I throw an error saying install #vitejs/plugin-vue. But when I try to install that it throws me those errors.

npm install vue#next vue-loader#next
npm i #vitejs/plugin-vue#2.3.3
composer require innocenzi/laravel-vite:0.2.*
npm i -D vite vite-plugin-laravel
vite.config.js
import { defineConfig } from 'vite'
import vue from '#vitejs/plugin-vue'
import laravel from 'vite-plugin-laravel'
export default defineConfig({
plugins: [
vue(),
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
],
refresh: true,
})
]
})
maybe you need to change app.js
import {createApp} from 'vue/dist/vue.esm-bundler.js';
or for async component add defineAsyncComponent
import {createApp, defineAsyncComponent} from 'vue/dist/vue.esm-bundler.js';
#vite() leave blank

If someone else is facing this issue add it directly to your package.json and then run npm i:
"#vitejs/plugin-vue": "^3.0.1"

Related

Error installing npm dependency in Laravel 8 Sail: Conflicting peer dependency: postcss

I have a laravel 8 project that I need to make changes to. I installed laravel sail to start it but I get an error trying to install npm packages:
sail npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: laravel-mix#6.0.18
npm ERR! Found: postcss#7.0.35
npm ERR! node_modules/postcss
npm ERR! postcss#"^7.0.35" from the root project
npm ERR! postcss#"^7" from #tailwindcss/postcss7-compat#2.0.3
npm ERR! node_modules/#tailwindcss/postcss7-compat
npm ERR! #tailwindcss/postcss7-compat#"^2.0.3" from the root project
npm ERR! 38 more (#types/cssnano, autoprefixer, css-declaration-sorter, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer postcss#"^8.1.2" from laravel-mix#6.0.18
npm ERR! node_modules/laravel-mix
npm ERR! dev laravel-mix#"^6.0.18" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: postcss#8.4.20
npm ERR! node_modules/postcss
npm ERR! peer postcss#"^8.1.2" from laravel-mix#6.0.18
npm ERR! node_modules/laravel-mix
npm ERR! dev laravel-mix#"^6.0.18" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /home/sail/.npm/_logs/2022-12-21T17_56_37_398Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in:
npm ERR! /home/sail/.npm/_logs/2022-12-21T17_56_37_398Z-debug-0.log
sail node -v
v18.12.1
sail npm -v
9.2.0

Laravel 9 Install vue router for vue 2.6.12

I try installing vue router with run command "npm install vue-router" but then showing error like this:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined#undefined
npm ERR! Found: vue#2.6.14
npm ERR! dev vue#"^2.6.12" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue#"^3.2.0" from vue-router#4.0.14
npm ERR! node_modules/vue-router
npm ERR! vue-router#"*" from the root project
npm ERR!
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See C:\Users\ACER\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ACER\AppData\Local\npm-cache_logs\2022-03-20T12_19_15_072Z-debug-0.log
please help
I solved it by installing vue-router#3.
npm install vue-router#3 --save
You can just try this.
Because your vue is not the latest version, it gives this error.
Use previous versions of vue-router.
To access old versions of vue-router, use the versions tab
Example : npm i vue-router#3.5.3

Heroku returning Error while running npm install

I'm running the follow command to push my app on Heroku 'git push heroku master', but it returns:
-----> Installing binaries
engines.node (package.json): 16.13.2
engines.npm (package.json): 8.1.2
Resolving node version 16.13.2...
Downloading and installing node 16.13.2...
npm 8.1.2 already installed with node
-----> Installing dependencies
Installing node modules (package.json)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: paper-kit-2-angular#1.4.0
npm ERR! Found: zone.js#0.11.3
npm ERR! node_modules/zone.js
npm ERR! zone.js#"0.11.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer zone.js#"~0.10.3" from #angular/core#11.0.4
npm ERR! node_modules/#angular/core
npm ERR! #angular/core#"11.0.4" from the root project
npm ERR! peer #angular/core#"11.0.4" from #angular/common#11.0.4
npm ERR! node_modules/#angular/common
npm ERR! #angular/common#"11.0.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /tmp/npmcache.GEG9a/eresolve-report.txt for a full report.
Can anyone help me?
Add your local "node" and "npm" version to package.json. For example I did:
"engines": {
"node": "16.15.1",
"npm": "8.5.5"
},
Apparently for me the "knex" module that I use is not compatible with newer npm (I am not sure).

Laravel8 npm run dev outputs: ERESOLVE unable to resolve dependency tree

Goal
Avoid error message.
I have been getting the following error message when I run the command npm run dev:
npm notice
npm notice New major version of npm available! 7.6.1 -> 8.1.4
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.4
npm notice Run npm install -g npm#8.1.4 to update!
npm notice
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: acorn#7.4.1
npm ERR! node_modules/acorn
npm ERR! acorn#"^7.0.0" from acorn-node#1.8.2
npm ERR! node_modules/acorn-node
npm ERR! acorn-node#"^1.6.1" from detective#5.2.0
npm ERR! node_modules/detective
npm ERR! detective#"^5.2.0" from tailwindcss#2.2.19
npm ERR! node_modules/tailwindcss
npm ERR! dev tailwindcss#"^2.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional acorn#"^8.5.0" from terser#5.10.0
npm ERR! node_modules/terser
npm ERR! terser#"^5.9.0" from laravel-mix#6.0.39
npm ERR! node_modules/laravel-mix
npm ERR! dev laravel-mix#"^6.0.6" from the root project
npm ERR! terser#"^5.7.2" from terser-webpack-plugin#5.2.5
npm ERR! node_modules/terser-webpack-plugin
npm ERR! terser-webpack-plugin#"^5.2.4" from laravel-mix#6.0.39
npm ERR! node_modules/laravel-mix
npm ERR! dev laravel-mix#"^6.0.6" from the root project
npm ERR! 1 more (webpack)
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/ml/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ml/.npm/_logs/2021-12-02T07_41_55_149Z-debug.log
Quick Solution:
I can avoid the problem / error message with the following command:
npm install --legacy-peer-deps.
Output:
npm WARN deprecated querystring#0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
added 807 packages, and audited 808 packages in 12s
84 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Question
What do I have to do to run npm install again without getting the error message?
I have the same issue too. I have fixed it using this line
npm i acorn --dev
then run again
npm install && install run dev
npm install npm#latest -g
then
npm install webpack-dev-server --save-dev
working for me
If you are using Laravel Homestead Package for any Vagrant Environment, then don't run the command inside the Vagrant Project Directory.
Go outside to the local directory of the project and run these commands.
image of commands inside vagrant
You should run these here::
image of commands outside vagrant

Laravel Tailwind authentication scaffolding issue

So I am currently playing around with Laravel and Tailwind. I have created a project and working through some initial views. The next to do was to add auth scaffolding to the project.
I tried Googling around, found https://aregsar.com/blog/2020/create-laravel-project-with-tailwind-ui-and-auth/. I also checked a couple of other results which had the same pointers.
So when I run composer require laravel-frontend-presets/tailwindcss --dev, no problems. Next up I run the following.
php artisan ui tailwindcss --auth
Tailwind CSS scaffolding installed successfully.
Tailwind CSS auth scaffolding installed successfully.
Please run "npm install && npm run dev" to compile your fresh scaffolding.
No issues...however, when I try and run npm install, I get the following...
npm install && npm run dev
npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency
tree npm ERR! npm ERR! While resolving: undefined#undefined npm ERR!
Found: tailwindcss#2.2.7 npm ERR! node_modules/tailwindcss npm ERR!
dev tailwindcss#"^2.2.6" from the root project npm ERR! npm ERR! Could
not resolve dependency: npm ERR! peer tailwindcss#"^1.3.3" from
#tailwindcss/ui#0.3.1 npm ERR! node_modules/#tailwindcss/ui npm ERR!
dev #tailwindcss/ui#"^0.3" from the root project npm ERR! npm ERR! Fix
the upstream dependency conflict, or retry npm ERR! this command with
--force, or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! See
/home/tam/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in: npm ERR!
/home/xxx/.npm/_logs/2021-07-26T19_33_44_249Z-debug.log
Stuck here. It's a pity as I prefer Tailwind to Bootstrap.
#tailwindcss/ui is no longer needed. Uninstall the #tailwindcss/ui package.
npm uninstall #tailwindcss/ui
Install latest dependencies for Laravel Mix, Autoprefixer, and PostCSS.
npm install -D laravel-mix#latest postcss#latest
autoprefixer#latest tailwindcss#latest
Finally, make sure the line...
require('#tailwindcss/ui'),
Is removed from your tailwind.config.js file.
Continue on with your compilation.
npm install && npm run dev

Resources