Getting error messages when running yarn commands

I am getting this odd error message. I noticed it when I tried to update Redwood. It does not seem to matter what yarn command I give, they all return the error.

Here is the full error message:

yarn run v1.22.11
$ /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/.bin/rw info
node:internal/modules/cjs/loader:361
      throw err;
      ^

Error: Cannot find module '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/yargs/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:353:19)
    at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@redwoodjs/cli/dist/index.js:12:37)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/yargs/package.json',
  requestPath: 'yargs'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any pointers on how to resolve this issue would be greatly appreaciated. Thank you.

If I look at the main entry in the referenced package.json it shows "main": "./index.js",

Hi @IsaacT8 Strange behavior indeed — looks like something is busted with Yarn.

Did you try either of the following (which sometimes is necessary after upgrading)?

  1. deleting all node_modules and re-installing or
  2. deleting and re-creating yarn.lock?

You can quickly delete all .gitignored (and unwatched) files via the following (warning: deletes EVERYTHING):

git clean -fdx -e .env

Note: the -e .env will save your .env file from being removed

Then run yarn install

If that doesn’t work. I’d try the same thing and also manually delete yarn.lock

Keep me posted!

Thank you @thedavid for the guidance. I was able to update Redwood to 0.36.4 after running git clean -fdx -e .env. I did not have to delete yarn.lock. However, I am now getting this new error:

yarn rw dev                                                                    ✔  6174  20:30:14
yarn run v1.22.11
$ /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/.bin/rw dev
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '@ardatan/aggregate-error'
Require stack:
- /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-tools/schema/node_modules/@graphql-tools/utils/index.cjs.js
- /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-tools/schema/index.js
- /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-tools/merge/index.js
- /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-codegen/core/index.cjs.js
- /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-codegen/cli/index.cjs.js
- /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@redwoodjs/internal/dist/generate/graphqlSchema.js
- /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@redwoodjs/internal/dist/generate/generate.js
- /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@redwoodjs/internal/dist/index.js
- /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@redwoodjs/cli/dist/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-tools/schema/node_modules/@graphql-tools/utils/index.cjs.js:8:40)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-tools/schema/node_modules/@graphql-tools/utils/index.cjs.js',
    '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-tools/schema/index.js',
    '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-tools/merge/index.js',
    '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-codegen/core/index.cjs.js',
    '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@graphql-codegen/cli/index.cjs.js',
    '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@redwoodjs/internal/dist/generate/graphqlSchema.js',
    '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@redwoodjs/internal/dist/generate/generate.js',
    '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@redwoodjs/internal/dist/index.js',
    '/Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@redwoodjs/cli/dist/index.js'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I came across this issue, which seems similar as it is related to graphql tools… Should I just wait till 0.37 or try something else? Thank you again for your help.

This is a strange one… :face_with_raised_eyebrow:

Do you have any comments in your SDL files? Any occurrence of the " char?

Unfortunately, I think you have something else going on here.

Maybe try deleting and re-creating yarn.lock. This feels like a resolution error of some kind.

One diagnosing hack would be to manually add the package to your root package.json. So try yarn add -W @ardatan/aggregate-error (-W for root workspace). See if the stack trace is different and/or more helpful.

1 Like

Thank you @thedavid for your help with this, I really appreciate it.

I checked the only sdl file in my app that I could find (it was at api/src/graphql/userExamples.sdl.js) and did not see any " character…

I moved on to deleting and re-creating the yarn.lock. That did not resolve the error message.

So, I gave yarn add -W @ardatan/aggregate-error a shot and then ran yarn rw dev. I was able to launch localhost:8910, but I did get this error message:

yarn run v1.22.11
$ /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/.bin/rw dev
$ /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/.bin/rw-gen-watch
$ /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/.bin/cross-env NODE_ENV=development NODE_OPTIONS=--enable-source-maps yarn nodemon --watch /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/redwood.toml --exec 'yarn rw-api-server-watch'
$ /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/.bin/cross-env NODE_ENV=development webpack serve --config /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/@redwoodjs/core/config/webpack.development.js
$ /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/.bin/nodemon --watch /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/redwood.toml --exec 'yarn rw-api-server-watch'
api | [nodemon] 2.0.12
api | [nodemon] to restart at any time, enter `rs`
api | [nodemon] watching path(s): redwood.toml
api | [nodemon] watching extensions: js,mjs,json
api | [nodemon] starting `yarn rw-api-server-watch`
$ /Users/isaactait/Desktop/Web_Dev/portfolio-site-2.0/node_modules/.bin/rw-api-server-watch
gen | Generating TypeScript definitions and GraphQL schemas...
gen | Failed to load schema
gen | Failed to load schema
gen |
gen | Error: Could not generate GraphQL schema
gen |
gen | Failed to load schema
gen | Failed to load schema
gen |
gen | Error: Could not generate GraphQL type definitions (api)
gen |
gen | 11 files generated
web |
web | "extendDefaultPlugins" utility is deprecated.
web | Use "preset-default" plugin with overrides instead.
web | For example:
web | {
web |   name: 'preset-default',
web |   params: {
web |     overrides: {
web |       // customize plugin options
web |       convertShapeToPath: {
web |         convertArcs: true
web |       },
web |       // disable plugins
web |       convertPathData: false
web |     }
web |   }
web | }
web |
api | Building... Took 490 ms
api | Starting API Server... Took 4 ms
api | Listening on http://localhost:8911/
api | Importing Server Functions...
web |
web | warn - You have enabled the JIT engine which is currently in preview.
web | warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
web | assets by path static/ 3.26 MiB
web |   assets by path static/media/ 458 KiB
web |     assets by path static/media/*.png 134 KiB 6 assets
web |     assets by path static/media/*.jpg 324 KiB
web |       asset static/media/tokyoBay.8c2ff155.jpg 226 KiB [emitted] [immutable] [from: src/pages/AboutPage/tokyoBay.jpg]
web |       asset static/media/profile.282be1ea.jpg 98.6 KiB [emitted] [immutable] [from: src/pages/AboutPage/profile.jpg]
web |   assets by path static/js/*.js 2.82 MiB 5 assets
web | asset favicon.png 221 KiB [emitted] [from: public/favicon.png] [copied]
web | asset README.md 1.9 KiB [emitted] [from: public/README.md] [copied]
web | asset index.html 529 bytes [emitted]
web | asset robots.txt 24 bytes [emitted] [from: public/robots.txt] [copied]
web | Entrypoint app 2.78 MiB (2.8 MiB) = static/js/runtime-app.bundle.js 48.8 KiB static/js/app.bundle.js 2.73 MiB 2 auxiliary assets
web | orphan modules 432 KiB [orphan] 115 modules
web | runtime modules 32.7 KiB 17 modules
web | modules by path ../node_modules/ 2.08 MiB 532 modules
web | modules by path ./src/ 265 KiB
web |   modules by path ./src/pages/ 28.8 KiB
web |     modules by path ./src/pages/HomePage/ 18.9 KiB 8 modules
web |     modules by path ./src/pages/AboutPage/ 4.64 KiB 4 modules
web |     2 modules
web |   modules by path ./src/*.js 4.04 KiB
web |     ./src/App.js 1.61 KiB [built] [code generated]
web |     ./src/Routes.js 2.43 KiB [built] [code generated]
web |   modules by path ./src/*.css 230 KiB
web |     ./src/index.css 2.13 KiB [built] [code generated]
web |     ../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[4].use[1]!../node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[4].use[2]!./src/index.css 228 KiB [built] [code generated]
web |   ./src/components/Footer.js 1.65 KiB [built] [code generated]
web | webpack 5.51.1 compiled successfully in 9673 ms
api | NOTICE: Redwood v1.0 will make resolvers secure by default.
api | To opt in to this behavior now, add `REDWOOD_SECURE_SERVICES=1` to your `.env.defaults` file. For more information: https://redwoodjs.com/docs/services
api | /graphql 6351 ms
api | ... Imported in 6352 ms
1 Like

I forgot to mention, but the build failed in Netlify too. I got the same error in the build logs that I reported here…

However, I pushed a new build after running yarn add -W @ardatan/aggregate-error to Netlify, and it successfully published.

Now to resolve the "extendedDefaultPlugins" utility is deprecated. and Failed to load schema errors. Perhaps I missed a code modification during a previous update?

Also strange as this would have to do with internal dependencies. Curious if you’re using the experimental Envelop/Helix GraphQL on your project?

gen | Error: Could not generate GraphQL schema

^^ these are all errors related to generating Types for your project. Not a dealbreaker but shouldn’t be happening regardless.

Perhaps I missed a code modification during a previous update?

^^ That’s what I’m wondering as well.

Any chance your repo is public and I could take a look?

I am not using Envelop/Helix GraphQL on my project.

My repo is public (link here) I would very much appreciate you taking a look at it :grimacing: :laughing:

Thank you for the offer.

Take a look at this PR:

I did find a lot to clean up, so hopefully your node_modules and yarn.lock work better going forward.

But I couldn’t figure out that pesky warning. My best guess is that it was from a dependency you installed, which is down to these two:

    "tailwindcss-gradients": "^3.0.0",
    "tailwindcss-hero-patterns": "^0.0.1"

But a quick look at the source for both didn’t reveal any webpack config for either.

So maybe something to do with Webpack handling the SVG file? Regardless, you can ignore.

Netlify

Lastly, you’ll see the Netlify preview is failing. This is because the build cache needs to be cleared (I’m mostly certain). From the failed preview, try the “Clear cached and deploy site” dropdown".

Screen Shot 2021-09-17 at 12.19.16 AM

1 Like

Wow! Thank you so much for all the work. I merged the pull request (and then pulled it down to my machine) and after clearing the cache in Netlify the build successfully built.

The only thing now is that when I run yarn rw dev or yarn redwood dev it comes back with the error: Command "rw" (or "redwood") not found. I came across this in the forum and tried yarn --force then re-ran yarn rw dev and the same error I first reported popped up again…

So, I ran git clean -fdx -e .env then yarn install and now everything is up and running. Not sure what was going on there, as you said in the pull request that everything was running fine locally for you… :man_shrugging:

Either way, I really appreciate your help and expertise with this. I am super psyched to have everything up and running 100% again.

1 Like

Great to hear!

What was happening (across contexts from local dev to deployment) is that your node_modules was out of sync with the actual dependencies in your project – i.e. you had packages that shouldn’t have been included and/or the wrong versions of packages included.

Because you were not .gitignoreing node_module, it was not being removed with git clean -fxd. So it never really got re-built.

And the same problem happens when you check in 'node_modules` and then deploy. Those same “incorrect” packages are pulled into the deployment build.

This explains why you had to go through the whole process again locally. You still had the “old” stuff on your computer, even after you merged and pulled down the changes.

Anyway, npm 101 pain points. We’ve all been there. And now you get to help the next person with this question! Deal?!?

:grin:

1 Like

:exploding_head:

Pretty cool all the way around, thank you for the explanation. Deal accepted, more than happy to help the next person :+1: :+1: :+1:

1 Like