question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`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');)
  • 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:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
zulaicacommented, Apr 23, 2021

Something we could do is run npx if running under npm and yarn run webpack if running via yarn — I think that’d work? I’d have to do some testing to check.

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.

1reaction
thecrypticacecommented, Apr 23, 2021

Something we could do is run npx if running under npm and yarn run webpack if running via yarn — I think that’d work? I’d have to do some testing to check.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found