`npx` causing issues with Yarn
See original GitHub issue- Laravel Mix Version: ^6.0.18 (
npm list --depth=0
) - Node Version (
node -v
): v14.16.0 - NPM Version (
npm -v
): 6.14.11 - Yarn Version: 2.x and 3.0.0-rc.2
- OS: macOS 11.2.3
Description:
The watch
and build
commands run npx
under the hood. This causes issues when using Yarn as the package manager and forces users to install webpack
and webpack-cli
as dependencies manually resulting in a confusing experience.
Steps To Reproduce:
- Create a project using Yarn as the package manager
- Add
laravel-mix
as a dev dependency - Add a
webpack.mix
file (or compatible variant)- This only needs to contain the import at the top of the file (
const mix = require('laravel-mix');
)
- This only needs to contain the import at the top of the file (
- Run
mix
using Yarn —yarn mix
On first run, the user is prompted to install webpack-cli
. If the user chooses to install at that time, the command then subsequently fails as it can’t find webpack
. In order to fix this issue, webpack
must also be installed as a dev dependency.
Solution:
Rather than running these commands with npx
, build
and watch
should call webpack
directly and both webpack
and webpack-cli
should be listed as peer dependencies.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
yarn equivalent of npx ? · Issue #3937 · yarnpkg/yarn - GitHub
For example my current issues with npx are: 1. it downloads absent package with dependencies every time, 2. it creates package-lock.
Read more >Is there any harm in using NPM and Yarn in the same project?
Although a few commenters here say its ok to mix both yarn and npm on the same project, after using yarn and npm...
Read more >Error Codes | Yarn - Package Manager
This error is usually caused by a Yarn plugin being missing. YN0011 - FETCHER_NOT_FOUND. A fetcher cannot be found for the given package....
Read more >Yarn vs NPM: Which One is Best to Choose? - KnowledgeHut
Yarn and NPM both support workspaces, allowing you to manage dependencies for numerous projects from a single repository. Using the npx command ...
Read more >Yarn vs npm: Everything You Need to Know - SitePoint
This means you have a single, top-level root package that has multiple child packages called workspaces. Running scripts remotely. The npx ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can give that a shot. I’ve got everything all set up and running at the moment, so it’s worth trying and reporting back.
Something we could do is run
npx
if running under npm andyarn run webpack
if running via yarn — I think that’d work? I’d have to do some testing to check.