You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding hot reload with yarn 2 in a new nest project runs the nest server successfully (i.e. curl localhost:3000 returns "Hello world"), but the output shows a deprecation warning and error messages related to requiring uninstalled packages.
(node:35944) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
(Use `node --trace-deprecation ...` to show where the warning was created)
and errors like
ERROR in ./.yarn/unplugged/@nestjs-core-virtual-330e9c6eb9/node_modules/@nestjs/core/nest-application.js 16:102-145
Module not found: Error: @nestjs/core tried to access @nestjs/websockets (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.
Required package: @nestjs/websockets (via "@nestjs/websockets/socket-module")
Required by: @nestjs/core@virtual:6847a7e26c6f65e9a07a05ac6fd51a817f487ca65a3f4eb6074a6e87e9e5a9b8d604589ccca3616c3ade1ca80766e0dab48ed3499f9be6e35afa8028ddc2857f#npm:7.6.1 (via /Users/bchinn/Desktop/yarn2/nest-hrm-yarn2/.yarn/unplugged/@nestjs-core-virtual-330e9c6eb9/node_modules/@nestjs/core/)
Ancestor breaking the chain: @nestjs/platform-express@virtual:6847a7e26c6f65e9a07a05ac6fd51a817f487ca65a3f4eb6074a6e87e9e5a9b8d604589ccca3616c3ade1ca80766e0dab48ed3499f9be6e35afa8028ddc2857f#npm:7.6.1
Ancestor breaking the chain: @nestjs/testing@virtual:6847a7e26c6f65e9a07a05ac6fd51a817f487ca65a3f4eb6074a6e87e9e5a9b8d604589ccca3616c3ade1ca80766e0dab48ed3499f9be6e35afa8028ddc2857f#npm:7.6.1
Ancestor breaking the chain: foo@workspace:.
@ ./.yarn/unplugged/@nestjs-core-virtual-330e9c6eb9/node_modules/@nestjs/core/index.js 25:21-50
@ ./src/main.ts 3:15-38
Now #5477 correctly added these packages to peerDependencies and specified them as optional with peerDependenciesMeta, but I think the way NestJS tries to load optional dependencies (i.e. try-catch require) triggers an error message with Yarn v2.
Bug Report
Adding hot reload with yarn 2 in a new nest project runs the nest server successfully (i.e.
curl localhost:3000returns "Hello world"), but the output shows a deprecation warning and error messages related to requiring uninstalled packages.Repro:
nest newyarn set version berry && yarnstart-server-webpack-pluginwithrun-script-webpack-plugin(Please upgrade to Webpack 5 ericclemmons/start-server-webpack-plugin#40 (comment))yarn add -D webpack@5.9.0(Move webpack to peerDependency for Yarn v2 + hot reload nest-cli#992)yarn start:devCurrent behavior
You'll see one deprecation warning:
and errors like
Now #5477 correctly added these packages to
peerDependenciesand specified them as optional withpeerDependenciesMeta, but I think the way NestJS tries to load optional dependencies (i.e. try-catchrequire) triggers an error message with Yarn v2.nest/packages/core/nest-application.ts
Lines 34 to 38 in 8c503d3
nest/packages/core/helpers/optional-require.ts
Lines 1 to 7 in 8c503d3
Input Code
See repro above
Expected behavior
yarn start:devshould not show any deprecation warnings or error messages, the way it displays without the "Add hot reload" step in the repro.Possible Solution
Some possible solutions:
optionalRequiredifferently, possibly using the PnP API to check if a package is installed before trying to require itEnvironment