Nx: yarn 2 / Plug N Play Support

Created on 27 Jan 2020  路  6Comments  路  Source: nrwl/nx

_Please make sure you have read the submission guidelines before posting an issue_

Prerequisites

Yarn version 2.0.0-rc.27

Expected Behavior

Should work correctly like before

Current Behavior

Build failure

Failure Information (for bugs)

An unhandled exception occurred: Cannot locate the 'node_modules' directory.
See "AppDataLocalTempng-mO3oFOangular-errors.log" for further details.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. yarn dlx @yarnpkg/doctor .
  2. yarn install
  3. yarn start

Context

Yarn has finally released a usable version two. If you using webpack 4 you need to enable PlugNPlay which is native to webpack 5

https://yarnpkg.com/advanced/migration
https://yarnpkg.com/advanced/pnpapi

Failure Logs

[error] Error: Cannot locate the 'node_modules' directory.
    at NgccProcessor.findNodeModulesDirectory (C:\dev\lec-migration\.yarn\$$virtual\@ngtools-webpack-virtual-9bdca6ad48\0\cache\@ngtools-webpack-npm-9.0.0-rc.10-6bfaf96715-1.zip\node_modules\@ngtools\webpack\src\ngcc_processor.js:113:15)
    at new NgccProcessor (C:\dev\lec-migration\.yarn\$$virtual\@ngtools-webpack-virtual-9bdca6ad48\0\cache\@ngtools-webpack-npm-9.0.0-rc.10-6bfaf96715-1.zip\node_modules\@ngtools\webpack\src\ngcc_processor.js:31:43)
    at C:\dev\lec-migration\.yarn\$$virtual\@ngtools-webpack-virtual-9bdca6ad48\0\cache\@ngtools-webpack-npm-9.0.0-rc.10-6bfaf96715-1.zip\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:554:33
    at SyncHook.eval [as call] (eval at create (C:\dev\lec-migration\.yarn\cache\tapable-npm-1.1.3-f1c2843426-1.zip\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:7:1)
    at SyncHook.lazyCompileHook (C:\dev\lec-migration\.yarn\cache\tapable-npm-1.1.3-f1c2843426-1.zip\node_modules\tapable\lib\Hook.js:154:20)
    at Object.webpack [as webpackFactory] (C:\dev\lec-migration\.yarn\cache\webpack-npm-4.41.2-efbe0580aa-1.zip\node_modules\webpack\lib\webpack.js:55:30)
    at createWebpack (C:\dev\lec-migration\.yarn\$$virtual\@angular-devkit-build-webpack-virtual-0beaa59de8\0\cache\@angular-devkit-build-webpack-npm-0.900.0-rc.10-7017fe1d56-1.zip\node_modules\@angular-devkit\build-webpack\src\webpack-dev-server\index.js:20:36)
    at Object.runWebpackDevServer (C:\dev\lec-migration\.yarn\$$virtual\@angular-devkit-build-webpack-virtual-0beaa59de8\0\cache\@angular-devkit-build-webpack-npm-0.900.0-rc.10-7017fe1d56-1.zip\node_modules\@angular-devkit\build-webpack\src\webpack-dev-server\index.js:46:12)
    at SwitchMapSubscriber.project (C:\dev\lec-migration\.yarn\$$virtual\@angular-devkit-build-angular-virtual-d79a835d58\0\cache\@angular-devkit-build-angular-npm-0.900.0-rc.10-f83f279b13-1.zip\node_modules\@angular-devkit\build-angular\src\dev-server\index.js:191:32)
    at SwitchMapSubscriber._next (C:\dev\lec-migration\.yarn\cache\rxjs-npm-6.5.3-bc949c0a94-1.zip\node_modules\rxjs\internal\operators\switchMap.js:49:27)
    at SwitchMapSubscriber.Subscriber.next (C:\dev\lec-migration\.yarn\cache\rxjs-npm-6.5.3-bc949c0a94-1.zip\node_modules\rxjs\internal\Subscriber.js:66:18)
    at C:\dev\lec-migration\.yarn\cache\rxjs-npm-6.5.3-bc949c0a94-1.zip\node_modules\rxjs\internal\util\subscribeToPromise.js:7:24
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Other

Documentation suggested you add the fallowing into .yarnrc.yml
nodeLinker: node-modules

When then produces the following error

Error: Something that got detected as your top-level application (because it doesn't seem to belong to any package) tried to access a package that is not declared in your dependencies       

Required package: @yarnpkg/fslib (via "@yarnpkg/fslib")
Required by: /C:/dev/lec-migration/node_modules/@yarnpkg/pnpify/lib/
third-party misc feature

Most helpful comment

According to this angular-cli comment this is no longer exactly the case.

It looks like native PnP mode support is not in yet, but @yarnpkg/pnpify or the node-modules linker strategy should (allegedly) be usable now.

Of course, I have no idea what this means for you guys, maybe this doesn't help you, but it's a thing now.

All 6 comments

Angular appears not to be supporting PNP yet. Tracking https://github.com/angular/angular-cli/issues/12465

According to this angular-cli comment this is no longer exactly the case.

It looks like native PnP mode support is not in yet, but @yarnpkg/pnpify or the node-modules linker strategy should (allegedly) be usable now.

Of course, I have no idea what this means for you guys, maybe this doesn't help you, but it's a thing now.

@ElbowBaggins CLI still now working. getting command nx not found

@FrozenPandaz

this issue is now relating to nx cli i believe https://github.com/nrwl/nx/blob/master/packages/cli/lib/init-local.tsit's looking directly in the node_module folder

I am seeing the same issue here and disappointed NX CLI is breaking builds on yarn2 given it is now at version 2.1. Our project fails to build with default yarn2 settings, i.e. pnp enabled, but works as expected in node-modules mode.

> yarn nx serve

/project-path/.pnp.js:34448
    throw firstError;
    ^

Error: Qualified path resolution failed - none of the candidates can be found on the disk.

Source path: /project-path/node_modules/@nrwl/tao/index.js

Looks like this does indeed relate to the cli looking for tao in the node_modules directory as @Jordan-Hall indicated.

Is it possible to get a fix for this any time soon?

I am seeing the same issue here and disappointed NX CLI is breaking builds on yarn2 given it is now at version 2.1. Our project fails to build with default yarn2 settings, i.e. pnp enabled, but works as expected in node-modules mode.

> yarn nx serve

/project-path/.pnp.js:34448
    throw firstError;
    ^

Error: Qualified path resolution failed - none of the candidates can be found on the disk.

Source path: /project-path/node_modules/@nrwl/tao/index.js

Looks like this does indeed relate to the cli looking for tao in the node_modules directory as @Jordan-Hall indicated.

Is it possible to get a fix for this any time soon?

Its annoying me now but im too ill to look. Ill carry on soon but they appears to be loads of files referencing direct file path grrr

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danieldanielecki picture danieldanielecki  路  3Comments

MichaelWarneke picture MichaelWarneke  路  3Comments

olakara picture olakara  路  3Comments

ZempTime picture ZempTime  路  3Comments

zpydee picture zpydee  路  3Comments