Tailwind CSS Laravel Mix Error - Forces PostCSS 8 to be installed - laravel

I recently created a new laravel 8 project using Breeze for the authentication and tailwind css. All worked perfectly when running npm run watch but once I run npm run prod I ran into errors. I noticed that the Tailwind docs mention that there are PostCSS issues so you need to unistall and run
npm install tailwindcss#npm:#tailwindcss/postcss7-compat #tailwindcss/postcss7-compat postcss#^7 autoprefixer#^9
I done that however every time I run npm run prod now the build quits at 98% and says
Additional dependencies must be installed. This will only take a moment.
Running: npm install postcss#^8.1 --save-dev --legacy-peer-deps
npm WARN browser-sync-webpack-plugin#2.2.2 requires a peer of webpack#^1 || ^2 || ^3 || ^4 but none is installed. You must install peer dependencies yourself.
Finished. Please run Mix again.
This auto updates PostCSS to 8.1 every time.
After that if I run npm run prod again it does the exact same message over and over.
I've tried removing the browsersync plugins and trying again but it still doesn't work.
Anyone ran into this or got a solution?

laravel-mix v6 now supports PostCSS8
According to tailwind docs, it suggests to use npm install tailwindcss#npm:#tailwindcss/postcss7-compat #tailwindcss/postcss7-compat postcss#^7 autoprefixer#^9
With the new Mix v6, run npm install tailwindcss#latest postcss#latest autoprefixer#latest
After this, npm run prod will run the way it should.

you must upgrade laravel mix using the following command
npm install laravel-mix#latest

As Digvijay mentioned above the new Mix v6 now supports PostCSS 8. So run:
npm install tailwindcss#latest postcss#latest autoprefixer#latest
After the when you run npm run prod you will still get this message:
Additional dependencies must be installed. This will only take a moment.
Running: npm install browser-sync browser-sync-webpack-plugin#2.2.2 --save-dev --legacy-peer-deps
npm WARN browser-sync-webpack-plugin#2.2.2 requires a peer of webpack#^1 || ^2 || ^3 || ^4 but none is installed. You must install peer dependencies yourself.
Finished. Please run Mix again.
To fix this just add sudo to the front of the npm command it ran:
sudo npm install browser-sync browser-sync-webpack-plugin#2.2.2 --save-dev --legacy-peer-deps
Now run npm run prod and it should work!

Related

Laravel 8, NPM Wepback API configuration problem, using Yarn on Ubuntu 20.04

Using npm run dev results in the error:
Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema. configuration.module.rules[10] has an unknown property 'loaders'
Jetstream Version: 1.6
Jetstream Stack: Livewire
Laravel Version: 8.14
PHP Version: 7.3.0
Database Driver & Version: MySQL v8.0
Steps to reproduce:
Navigate to directory hosting Laravel 8 project
Run command rm -rf node_modules and wait for the command to complete
Run command rm package-lock.json
Run command npm cache clear --force
Run command sudo npm install --global npm - this updates NPM (Node Package Manager)
Run command sudo yarnpkg install
Run command sudo yarnpkg add babel#latest
Run command sudo yarnpkg add webpack#latest
Run command sudo yarnpkg add webpack-cli#latest
Run command sudo yarnpkg add vue-template-compiler --save-dev --production=false
Run command sudo yarnpkg add sass-loader#8.* sass --save-dev --production=false
Run command sudo npm install --global cross-env
Run command yarnpkg run dev
NPM is supposed to return a success message, but clearly something is either broken or misconfigured...
Problem has been solved through either an NPM or Yarn update

NPM run watch resulting in error Laravel 5.7

I am receiving this error when I try to run npm run watch
Error: Cannot find module 'C:\wamp64\www\node_modules\laravel-mix\setup\webpack.config.js'
I am currently using
Laravel Framework 5.7.16
NPM 6.4.1
Thank you in advance
Edit: yes, I have run npm install
You have to first install your node modules with:
npm install
It seems that you don't have the package Laravel-mix, install it running:
npm install laravel-mix --save-dev
Also check if you have your webpack.config.js inside the main folder of your app, if not check for the docs on how to get it: https://laravel-mix.com/docs/3.0/installation

Laravel Mix: These dependencies were not found:

I have a fresh install of Laravel 5.4. I as well have the folowing versions installed on my Windows PC
node: 6.11.0
npm:5.0.3
I have already run npm install, however, when i run npm run watch, i get the following error
> # watch C:\xampp\htdocs\tu
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
10% building modules 1/1 modules 0 active
Webpack is watching the files…
95% emitting
ERROR Failed to compile with 2 errors 12:12:42 AM
These dependencies were not found:
* C:\xampp\htdocs\tu\resources\assets\js\app.js in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss
* C:\xampp\htdocs\tu\resources\assets\sass\app.scss in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss
To install them, you can run: npm install --save C:\xampp\htdocs\tu\resources\assets\js\app.js C:\xampp\htdocs\tu\resources\assets\sass\app.scss
I've searched the internet but cant seem to get it working. Any help is appreciated.
I was having the exact same issue but Leo_Kelmendi's solution didn't work for me.
Searching on GitHub, I found there is a bug in NPM 5.2.0 that affects Laravel Mix. Read more about it here.
I had to revert NPM to its previous version in order to get my assets compiling again:
$ sudo npm install -g npm#5.1.0
Then, I removed all installed modules:
$ rm -rf node_modules/
$ npm cache clear --force
$ rm -rf package-lock.json
Notice that clearing the cache may take a while.
And, finally, I reinstalled node deps and run the dev script:
$ npm install
$ npm run dev
Try to revert to this package.json. You can find it here:
https://github.com/laravel/laravel/blob/c1643bf0c59b6864fc55e09cce3bfafc67d29e2a/package.json
And try to run it again, also make sure, there's a node_modules/moment folder.

Ionic / Cordova installation failure

Can you help me to resolve the problem with Ionic and Cordova shown in the screenshot below?
Update to latest npm and run as non-admin (if you were) and give it a try again.
npm install -g npm
or first try updating packages
npm update -g
Update npm to latest version and check again.
npm install -g npm
If problem persists then update the node also.
Then you are good to go.

Command error running installed npm modules

Hi guys could you help me? i've installed the latest version of node.js and installed cordova and ionic framework the problem starts is when i'm trying to run the ionic command, the console throw me the following message:
MacBook-Pro-de-Diego:~ diegochavez$ ionic start myApp
-bash: ionic: command not found
So then i looked for the root of my npm modules
MacBook-Pro-de-Diego:~ diegochavez$ npm root
/Users/diegochavez/node_modules
if you guys know something to fix this? Thanks in advance
First check if ionic is installed at path like /usr/local/lib/node_modules/ionic/bin/ionic. If it is there, you need to check the npm default global path.
Run command npm config get prefix to check the default path, it should be /usr/local. If it is not /usr/local, run command npm config set prefix /usr/local to set it. And then install again. Also see this answer
I having issue while running - sudo npm install -g gulp ionic with below version of node installed
node -v v0.10.15
npm -v 1.3.5
Error went way after I update node to latest version v0.10.26
The error you are getting is because ionic was not installed successfully. Trying updating node and run command as mentioned sudo npm install -g gulp ionic
Check where your npm folder is located. If your npm folder is located in $Home..then type this:
export PATH="$HOME/npm/bin:$PATH"
You need to run sudo npm install -g ionic from the command line.

Resources