Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Yarn 2, especially regarding stricter peerDependencies constraints #7581

Closed
Demivan opened this issue Aug 6, 2020 · 28 comments
Closed

Comments

@Demivan
Copy link

Demivan commented Aug 6, 2020

Describe the bug
Quasar does not specify Vue as peer dependency but imports from it.
I'm using yarn@2 and it much stricter and is not allowing package to use other packages without specifying them as dependencies.

Codepen/jsFiddle/Codesandbox (required)
https://github.com/Demivan/quasar-yarn-2-issue

To Reproduce
Steps to reproduce the behavior:

  1. Checkout repository
  2. run yarn build
  3. See build error.

Expected behavior
No build error should be produced.

Screenshots
With webpack

ERROR in ./.yarn/cache/quasar-npm-1.12.13-43fa104864-2.zip/node_modules/quasar/src/utils/open-url.js 1:0-21
Module not found: Error: A package is trying to access another package without the second one being listed as a dependency of the first one

Required package: vue (via "vue/dist/vue.runtime.esm.js")
Required by: quasar@npm:1.12.13 (via ./.yarn/cache/quasar-npm-1.12.13-43fa104864-2.zip/node_modules/quasar/src/utils/)

With rollup:

(node:139528) [MODULE_NOT_FOUND] Error: quasar tried to access vue, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(Use `node --trace-warnings ...` to show where the warning was created)

Platform (please complete the following information):
Yarn: yarn@2 berry

Additional context
Fix using .yarnrc.yml: https://github.com/Demivan/quasar-yarn-2-issue/blob/fix/.yarnrc.yml

@IlCallo
Copy link
Member

IlCallo commented Aug 11, 2020

We haven't tested Quasar on Yarn 2 yet, so we cannot assure compatibility.

Thanks for reporting and suggesting a fix, this could help the community while we still doesn't officially support it.
Keep suggesting fixes and providing resources if you find others, this could help us when we start tackling this problem :)

About peerDependencies here you can read about why Quasar doesn't use them.
#4606 (comment)

@IlCallo IlCallo changed the title Quasar does not specify Vue as peer dependency but imports from it Support Yarn 2, expecially regarding stricter peerDependencies constraints Aug 11, 2020
@IlCallo IlCallo changed the title Support Yarn 2, expecially regarding stricter peerDependencies constraints Support Yarn 2, especially regarding stricter peerDependencies constraints Aug 11, 2020
@Demivan
Copy link
Author

Demivan commented Aug 25, 2020

Quasar cli create command is incompatible with Yarn 2. Cause is consolidate package that is not specifying peer dependencies properly too.
Quasar cli uses it to render handlebars templates. That code can be easily switched to using handlebars package directly and consolidate can be removed.

@pdanpdan
Copy link
Collaborator

cross ref:
#8245
#8286
#7581

@Robula
Copy link

Robula commented Mar 16, 2021

quasar upgrade fails too. yarn info <package> --json returns a different object to what is expected.
EDIT: I'm experiencing #8245

@rstoenescu
Copy link
Member

Please use Yarn v1 for the moment.
The v2 of Yarn has some hard requirements that forces us to not be able to provide a good developer experience.

We have plans to create a CLI based on Vite instead of Webpack and that will allow us to officially support Yarn 2.

@Robula
Copy link

Robula commented Nov 3, 2021

@rstoenescu Could Quasar at least support Yarn 2 with nodeLinker: node-modules for the time being? I depend heavily on workspaces and the tools that Yarn 2 provides.

Thanks

@namespace-github
Copy link

@rstoenescu Will Quasar support yarn 2 with webpack in the future? We rely on webpack and cannot switch to vite for various reasons.

@maggie44
Copy link
Contributor

To share some experiences from the last few days, yarn 2 (now yarn 3) is a very different kettle of fish. Has been very difficult to integrate in to a project (not a Quasar project, something even simpler), it seems to have largely abandoned the idea of production vs development builds, does not adhere to the NODE_ENV variable, makes Docker files significantly longer and more complicated, and without production flags hasn't reduced the size of the package (there are some ways to get production builds, but it requires additional plugins to be installed, it seems the general direction they are heading is to keep one flat package.json file for everything).

Inevitably I am sure there will be a Quasar transition to the latest yarn, but wanted to flag that it may not be all roses and rainbows, be careful what we wish for.

@IlCallo
Copy link
Member

IlCallo commented Apr 14, 2022

Note that since we externalized many of the dependencies for which we controlled and pinned versions (vue, vuex, vue-router) in order to support Vite with the new CLI, it should now be possible to use Yarn2 with latest Quasar app-webpack and app-vite packages, as well as latest NPM and PNPM package managers

@maggie44
Copy link
Contributor

Note that since we externalized many of the dependencies for which we controlled and pinned versions (vue, vuex, vue-router) in order to support Vite with the new CLI, it should now be possible to use Yarn2 with latest Quasar app-webpack and app-vite packages, as well as latest NPM and PNPM package managers

I did have some success with that:

yarn set version stable
yarn install

Update the .gitignore files: https://yarnpkg.com/getting-started/qa/#which-files-should-be-gitignored

At this stage though it is in the compatibility mode, using the legacy node_modules folder.

Removing nodeLinker: node-modules from .yarnrc.yml should change it to the new mode. But generates an error:

yarn dev  

 .d88888b.
d88P" "Y88b
888     888
888     888 888  888  8888b.  .d8888b   8888b.  888d888
888     888 888  888     "88b 88K          "88b 888P"
888 Y8b 888 888  888 .d888888 "Y8888b. .d888888 888
Y88b.Y8b88P Y88b 888 888  888      X88 888  888 888
 "Y888888"   "Y88888 "Y888888  88888P' "Y888888 888
       Y8b

(node:18312) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'version' of undefined
    at Object.<anonymous> (/Users/user/Documents/GitHub.nosync/balena-device-ui/ui/.yarn/__virtual__/@quasar-app-vite-virtual-89b86ecc42/0/cache/@quasar-app-vite-npm-1.0.0-beta.14-25bb27949e-d5718d0401.zip/node_modules/@quasar/app-vite/lib/helpers/banner-global.js:6:43)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Object.require$$0.Module._extensions..js (/Users/user/Documents/GitHub.nosync/balena-device-ui/ui/.pnp.cjs:14194:33)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.require$$0.Module._load (/Users/user/Documents/GitHub.nosync/balena-device-ui/ui/.pnp.cjs:14034:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/Users/user/Documents/GitHub.nosync/balena-device-ui/ui/.yarn/__virtual__/@quasar-app-vite-virtual-89b86ecc42/0/cache/@quasar-app-vite-npm-1.0.0-beta.14-25bb27949e-d5718d0401.zip/node_modules/@quasar/app-vite/lib/helpers/print-dev-banner.js:5:64)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:18312) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:18312) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@IlCallo
Copy link
Member

IlCallo commented Apr 14, 2022

Thanks for reporting, have you tried with Yarn 3 too?

@maggie44
Copy link
Contributor

maggie44 commented Apr 14, 2022

This is Yarn 3, I haven't tried with Yarn 2.

3.2.0

I have decided to abandon it and stick with Yarn 1. Nothing to do with Quasar, it's all on the Yarn end. I got about as far as trying to get Visual Studio Code to read from zip files instead of node_modules, which involved extensions for reading from Zip files, and the usual VSC dramas. Maybe in a few versions time the docs will be better and the integration smoother for the newer yarn.

@RovshenTagangylyjov
Copy link

RovshenTagangylyjov commented Apr 24, 2022

Do we still have to use yarn v1 or can we use v2 or higher after quasar cli 1.3?

@MilosPaunovic
Copy link
Member

Yarn 1 is still the only one fully supported.

@NGPixel
Copy link

NGPixel commented Apr 30, 2022

Yarn 3 works perfectly fine as long as you set nodeLinker: node-modules in your .yarnrc.yml

Proper pnp mode support would be great in the future though...

@taai
Copy link

taai commented May 11, 2022

I tried installing dependencies with pnpm without setting shameful-hoist setting and had the same issue @Maggie0002 had. So I got my hands dirty. 🔍

The problem appears to be with resolving dependencies only relative to appPaths.appDir in get-package-json.js

That line should be replaced with this:

paths: [ folder ].concat(module.paths)

It would make the resolver first to look in the specified directory and then in default paths. Then it works also with pnpm even without using shameful-hoist setting.

So, the file get-package-json.js should look like this:

const appPaths = require('../app-paths')

module.exports = function (pkgName, folder = appPaths.appDir) {
  if (pkgName === '@quasar/app-vite') {
    return require('../../package.json')
  }

  try {
    return require(
      require.resolve(`${pkgName}/package.json`, {
        paths: [ folder ].concat(module.paths)
      })
    )
  }
  catch (e) {}
}

@yusufkandemir
Copy link
Member

@Maggie0002 @taai the error regarding resolving Vite's version (TypeError: Cannot read property 'version' of undefined) will be addressed in #13609.

@maggie44
Copy link
Contributor

maggie44 commented Aug 24, 2022

Another related yarn support issue, when running a build for electron it passes the --production flag which is deprecated:

yarn workspace ui build -m electron

 App • Running "yarn install --production" in /Users/user/Documents/GitHub.nosync/balena-device-ui/ui/dist/electron/UnPackaged

➤ YN0050: The --production option is deprecated on 'install'; use 'yarn workspaces focus' instead

 App • Command "yarn" failed with exit code: 1

 App • ⚠️   FAIL  yarn failed installing dependencies

Rather than open a new issue, knowing that yarn > 1 isn't yet officially supported, adding here.

Any thoughts on workaround appreciated

@customautosys
Copy link
Contributor

Another related yarn support issue, when running a build for electron it passes the --production flag which is deprecated:

yarn workspace ui build -m electron

 App • Running "yarn install --production" in /Users/arranmagee/Documents/GitHub.nosync/balena-device-ui/ui/dist/electron/UnPackaged

➤ YN0050: The --production option is deprecated on 'install'; use 'yarn workspaces focus' instead

 App • Command "yarn" failed with exit code: 1

 App • ⚠️   FAIL  yarn failed installing dependencies

Rather than open a new issue, knowing that yarn > 1 isn't yet officially supported, adding here.

Any thoughts on workaround appreciated

Dear @rstoenescu,

I am facing the exact same issue.

@maggie44
Copy link
Contributor

Perhaps I should have created this as a separate issue for tracking?

@IlCallo
Copy link
Member

IlCallo commented Oct 13, 2022

@Maggie0002 yes, please do

@maggie44
Copy link
Contributor

Logged here: #14618

@erhard
Copy link

erhard commented May 6, 2023

Yarn2 is not recommended with quasar (see above) yet yarn 1 does not support private repos in addition to public repos. So I try to migrate to npm . Where is it configured which package - manager is to be used with the latest quasar version. The problem is yarn is called from quasar ext add @bla/package-Id. But it should call npm

@erhard
Copy link

erhard commented May 6, 2023

Found the solution myself.....removed yarn from engine in package.json

@Dirk-
Copy link

Dirk- commented Jun 26, 2024

Yarn 3 works perfectly fine as long as you set nodeLinker: node-modules in your .yarnrc.yml

@NGPixel Is this still working? For Quasar CLI with Vite? Anything else to put into .yarnrc.yml?

@yusufkandemir
Copy link
Member

@Dirk- I would kindly say the best way is trying it out rather than asking a question in an issue that was closed 8 months ago.

nodeLinker values node-modules and potentially pnpm should both work fine. But, we still recommend Yarn v1 as we haven't officially confirmed or battle-tested this solution. If more people report Yarn v3/v4 works fine this way, we can update our view on this. Thanks.

@Dirk-
Copy link

Dirk- commented Jun 26, 2024

@Dirk- I would kindly say the best way is trying it out rather than asking a question in an issue that was closed 8 months ago.

Sure. I forgot to mention @NGPixel in my reply, I was just asking for his experience. "Trying it out" usually means going down the rabbit hole for hours or days in JavaScript-based projects... This is why I like Quasar so much, it frees me from these hassle.

nodeLinker values node-modules and potentially pnpm should both work fine. But, we still recommend Yarn v1 as we haven't officially confirmed or battle-tested this solution. If more people report Yarn v3/v4 works fine this way, we can update our view on this. Thanks.

OK, thanks. I probably need yarn v3 or v4 to get an Electron app with a native module packaged.

@customautosys
Copy link
Contributor

Hi Dirk, fix had been committed already: #15747 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment