Skip to content

Yarn 'PnP' functionality does not work on windows: You cannot require a package that is not declared in your dependencies #6860

Closed
@nicewaytodoit

Description

@nicewaytodoit

Currently installed:
node version: v10.15.0
yarn version: 1.12.3
react-scripts: 2.1.2
Windows 10 x64

I have tried few things to enable PnP but neither works. First I've tried enabling it on existing project and it did not work. Then installing it as new react app with:

yarn create react-app hello-yarn --use-pnp

But it still created node_module files.
After I deleted node_module files, and tried running yarn --enable-pnp cash was created but at the same time there was V3 and V4 folder.
Still no luck. Then deleted Cache and configured yarn config set cache-folder /c/proj/YarnCache
So config file looks like this:

info yarn config
{ 'version-tag-prefix':
   'v',
  'version-git-tag':
   true,
  'version-commit-hooks':
   true,
  'version-git-sign':
   false,
  'version-git-message':
   'v%s',
  'init-version':
   '1.0.0',
  'init-license':
   'MIT',
  'save-prefix':
   '^',
  'bin-links':
   true,
  'ignore-scripts':
   false,
  'ignore-optional':
   false,
  registry:
   'https://registry.yarnpkg.com',
  'strict-ssl':
   true,
  'user-agent':
   'yarn/1.12.3 npm/? node/v10.15.0 win32 x64',
  'cache-folder':
   'C:\\proj\\YarnCache',
  lastUpdateCheck:
   1546153614636 }

(by the way I do not have a clue why is JSON config looks all unaligned and borken)

Went again into the project and again run yarn --enable-pnp
Checked the cache, it is created successfully with all hash file keys within folder 'C:\proj\YarnCache',

When I run project yarn start I get following error

C:\proj\Test\hello-yarn-pnp\.pnp.js:15511
    throw firstError;
    ^
**Error: You cannot require a package ("C:\proj\YarnCache\v4\npm-react-scripts-2.1.2-cf1686cd9ca3c6148e1428e97
aac12995f01b554\node_modules\react-scripts\bin\react-scripts.js") that is not declared in your dependencies**
(via "C:\proj\Test\hello-yarn-pnp/")
    at makeError (C:\proj\Test\hello-yarn-pnp\.pnp.js:55:17)
    at Object.resolveToUnqualified (C:\proj\Test\hello-yarn-pnp\.pnp.js:15244:17)
    at Object.resolveRequest (C:\proj\Test\hello-yarn-pnp\.pnp.js:15322:31)
    at Function.Module._resolveFilename (C:\proj\Test\hello-yarn-pnp\.pnp.js:15502:30)
    at Function.Module._load (C:\proj\Test\hello-yarn-pnp\.pnp.js:15420:31)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Additionally I have tried deleting yarn.lock, .pnp file and folder and running again yarn -pnp everything went smoothly but again without luck, I am getting the same dependency error.

To emphasize: Project has been created with yarn crate react-app --use-pnp
If I remove pnp option and install packages in standard way project will run perfectly fine.

What is the expected behavior?

I expect project to run without errors :)

Does anyone has a clue what is going on and is it yarn issue or my system configuration issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions