Skip to content

Yarn 3 dev commands fails with missing deps #35140

@graysonhicks

Description

@graysonhicks

Preliminary Checks

Description

When starting a Gatsby project with Yarn 3, the install works correctly, but when trying to run gatsby develop you get the following error:

Error: Your application tried to access gatsby-parcel-config, but it isn’t declared in your dependencies; this makes the require call ambiguous and unsound.

This leads to this section of the Yarn docs. Which recommends:

Or the code has to be modified in order to use the paths option from require.resolve: require(require.resolve(jest-environment-${config.environment}, {paths:[config.projectPath]})) (note that this is the recommended option, being unintrusive for users and a good idea in general)

But this line seems to be already using paths in resolve correctly.

if you manually yarn add gatsby-parcel-config --dev the error goes away but then it just throws the same for the next gatsby dep (dontev), which doesn’t seem right.

Reproduction Link

https://github.com/graysonhicks/gatsby-yarn3-deps-bug

Steps to Reproduce

  1. git clone [email protected]:graysonhicks/gatsby-yarn3-deps-bug.git
  2. cd gatsby-yarn3-deps-bug
  3. nvm use
  4. yarn
  5. yarn start

Expected Result

Local up and running.

Actual Result

There was an unhandled error during compilation for
/Users/graysonhicks/Documents/Development/yarn3-test. Please run the command with the --verbose flag
 again.



  Error: Your application tried to access gatsby-parcel-config, but it isn't declared in your depend
  encies; this makes the require call ambiguous and unsound.
  Required package: gatsby-parcel-config
  Required by: /Users/graysonhicks/Documents/Development/yarn3-test/
  Require stack:
  - /Users/graysonhicks/Documents/Development/yarn3-test/.yarn/unplugged/gatsby-virtual-55bb897422/n
  ode_modules/gatsby/dist/utils/parcel/compile-gatsby-files.js
  - /Users/graysonhicks/Documents/Development/yarn3-test/.yarn/unplugged/gatsby-virtual-55bb897422/n
  ode_modules/gatsby/dist/bootstrap/get-config-file.js
  - /Users/graysonhicks/Documents/Development/yarn3-test/.yarn/unplugged/gatsby-virtual-55bb897422/n
  ode_modules/gatsby/dist/bootstrap/load-config/index.js
  - /Users/graysonhicks/Documents/Development/yarn3-test/.yarn/unplugged/gatsby-virtual-55bb897422/n
  ode_modules/gatsby/dist/services/initialize.js
  - /Users/graysonhicks/Documents/Development/yarn3-test/.yarn/unplugged/gatsby-virtual-55bb897422/n
  ode_modules/gatsby/dist/services/index.js
  - /Users/graysonhicks/Documents/Development/yarn3-test/.yarn/unplugged/gatsby-virtual-55bb897422/n
  ode_modules/gatsby/dist/state-machines/develop/services.js
  - /Users/graysonhicks/Documents/Development/yarn3-test/.yarn/unplugged/gatsby-virtual-55bb897422/n
  ode_modules/gatsby/dist/state-machines/develop/index.js
  - /Users/graysonhicks/Documents/Development/yarn3-test/.yarn/unplugged/gatsby-virtual-55bb897422/n
  ode_modules/gatsby/dist/commands/develop-process.js
  - /Users/graysonhicks/Documents/Development/yarn3-test/.cache/tmp-54011-e7J7NL2RgeY5

  - .pnp.cjs:28270 Function.require$$0.Module._resolveFilename
    /Users/graysonhicks/Documents/Development/yarn3-test/.pnp.cjs:28270:13

  - helpers:108 Function.resolve
    node:internal/modules/cjs/helpers:108:19

  - compile-gatsby-files.ts:20 constructParcel
    [gatsby-virtual-55bb897422]/[gatsby]/src/utils/parcel/compile-gatsby-files.ts:20:28

  - compile-gatsby-files.ts:45 compileGatsbyFiles
    [gatsby-virtual-55bb897422]/[gatsby]/src/utils/parcel/compile-gatsby-files.ts:45:20

  - initialize.ts:171 initialize
    [gatsby-virtual-55bb897422]/[gatsby]/src/services/initialize.ts:171:9

  - interpreter.js:859 Interpreter.exec
    [xstate-npm-4.30.6-e139413d54-ee34698cbd.zip]/[xstate]/lib/interpreter.js:859:61

  - interpreter.js:205 Interpreter.execute
    [xstate-npm-4.30.6-e139413d54-ee34698cbd.zip]/[xstate]/lib/interpreter.js:205:14

  - interpreter.js:231 Interpreter.update
    [xstate-npm-4.30.6-e139413d54-ee34698cbd.zip]/[xstate]/lib/interpreter.js:231:12

  - interpreter.js:480
    [xstate-npm-4.30.6-e139413d54-ee34698cbd.zip]/[xstate]/lib/interpreter.js:480:13

  - scheduler.js:69 Scheduler.process
    [xstate-npm-4.30.6-e139413d54-ee34698cbd.zip]/[xstate]/lib/scheduler.js:69:7

  - scheduler.js:32 Scheduler.initialize
    [xstate-npm-4.30.6-e139413d54-ee34698cbd.zip]/[xstate]/lib/scheduler.js:32:12

  - interpreter.js:479 Interpreter.start
    [xstate-npm-4.30.6-e139413d54-ee34698cbd.zip]/[xstate]/lib/interpreter.js:479:20

  - develop-process.ts:162 module.exports
    [gatsby-virtual-55bb897422]/[gatsby]/src/commands/develop-process.ts:162:11

  - task_queues:96 processTicksAndRejections
    node:internal/process/task_queues:96:5


not finished compile gatsby files - 0.060s

Environment

System:
    OS: macOS 11.2.3
    CPU: (8) arm64 Apple M1
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    Yarn: 3.2.0 - ~/.nvm/versions/node/v16.13.1/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 99.0.4844.51
    Safari: 14.0.3

Config Flags

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: confirmedIssue with steps to reproduce the bug that’s been verified by at least one reviewer.type: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions