[Blog Tutorial] - Auth Setup and Storybook - Yarn Workspace Errors

I’ve already wrote this in Discord and a Core Member told me, that i should crosspost it here in the forum. I will post a link to the Discord Post first and then describe my problem here, too.

Discord Link:

Problem Description:

I’m at the point in the tutorial where i have to run

yarn rw setup auth dbAuth

When I do this, i get the following Error Message:

error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

I know it has something to to with the yarn workspaces but i don’t want to screw up my tutorial setup by using the W flag. What is the correct way to solve this?

I got the error with redwood version 7.1.0 and yarn 1.22.19. I upgraded to 7.1.1 and also 7.1.2. but this doesn’t help.

I also noticed, that there is a similar problem when i want to start storybook with “yarn rw storybook”. then, the following error is displayed:

> yarn rw storybook
yarn run v1.22.19
$ /Users/tobias/Workspace/redwoodblog/node_modules/.bin/rw storybook
Installing plugin "@redwoodjs/cli-storybook"...
error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Error: Command failed with exit code 1: yarn add -D @redwoodjs/cli-storybook@7.1.1
    at makeError (/Users/tobias/Workspace/redwoodblog/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/Users/tobias/Workspace/redwoodblog/node_modules/execa/index.js:118:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async installRedwoodModule (/Users/tobias/Workspace/redwoodblog/node_modules/@redwoodjs/cli/dist/lib/packages.js:85:5)
    at async installPluginPackage (/Users/tobias/Workspace/redwoodblog/node_modules/@redwoodjs/cli/dist/lib/plugin.js:214:5)
    at async loadPluginPackage (/Users/tobias/Workspace/redwoodblog/node_modules/@redwoodjs/cli/dist/lib/plugin.js:159:21)
    at async loadCommandsFromCacheOrPackage (/Users/tobias/Workspace/redwoodblog/node_modules/@redwoodjs/cli/dist/plugin.js:262:18)
    at async loadPlugins (/Users/tobias/Workspace/redwoodblog/node_modules/@redwoodjs/cli/dist/plugin.js:197:22)
    at async runYargs (/Users/tobias/Workspace/redwoodblog/node_modules/@redwoodjs/cli/dist/index.js:188:3)
    at async /Users/tobias/Workspace/redwoodblog/node_modules/@redwoodjs/cli/dist/index.js:137:7 {
  shortMessage: 'Command failed with exit code 1: yarn add -D @redwoodjs/cli-storybook@7.1.1',
  command: 'yarn add -D @redwoodjs/cli-storybook@7.1.1',
  escapedCommand: 'yarn add -D "@redwoodjs/cli-storybook@7.1.1"',
  exitCode: 1,
  signal: undefined,
  signalDescription: undefined,
  stdout: undefined,
  stderr: undefined,
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
2 Likes

Hey @tobias.bruns :wave:

I think when you run yarn within a redwood project we would expect it to be at v4.1.0 (or somewhere close to that). This happens for you automatically when you have node’s corepack enabled. That will read the package.json we generated during project creation and use the version of node that we asked for.

I wonder did you manage to read through this page on the tutorial chapter 1 Prerequisites | RedwoodJS Docs? Specifically here:

It may be the case now that you have things in your project that could be messing with it, such as config in your .yarnrc.yml file that would dictate a path to a yarn binary directly. This guide here may be helpful.

(Also I didn’t look into the discord link so apologies If I’m repeating stuff you’ve already debugged!)

Hey Josh,
thank’s for the reply. I’m using nvm and just installed the latest version of yarn with “npm i -g yarn” (at least I thought so). the documentation says >=1.22.21 so i thought that the 1.x branch is the current branch. there is no version 1.22.21. the latest version of the 1.x branch is 1.22.19 and that is the version i have installed.
anyway, i will try to use a newer version of yarn today (and trying corepack) and this will most likely solve my problem. i will write here again when i have tested it.

1 Like

I tried it with yarn 4.1.1 and it now works as expected. Thanks again for the hint with the yarn version. I probably wouldn’t have thought of it so quickly because i thought i was definitely using an up-to-date version.

1 Like

No problem! Honestly, it is super easy to accidentally install yarn incorrectly and the first link on google is a link to old docs where the warning banner isn’t all that bold. I’m glad it’s working and thanks for using redwood!

Hey @Josh-Walker-GM et al., I ran into the same problem and unfortunately updating to Yarn v4.1.0 hasn’t resolved the issue for me. Now I’m getting this new error messaging. Any ideas?

Edit: I gave up on using my own codebase from the first half of the tutorial and started with a fresh fork of the example repo.

node:internal/modules/cjs/loader:1147
throw err;
^

Error: Cannot find module ‘y18n’
Require stack:
… {
code: ‘MODULE_NOT_FOUND’,
requireStack: [

]
}

Node.js v20.11.1

Update: RESOLVED! I shut down my machine, started it back up, then re-ran these commands and it’s working now :person_shrugging:

yarn install
yarn rw prisma migrate dev (which reported it was already in sync)
npm install --global yarn (now says I’m on v3.6.3)
yarn rw storybook

2 Likes

I have the same problems.
I try to use yarn 4.1.1 and other versions and the error persists, I open an issue on github and a post here in the community but I didn’t get a response