Closed SirPhemmiey closed 6 months ago
I will be closing this as i've found out that simply updating webpack to the latest version will most likely fix this. Current version is v5.91.0
I reopened this again because i had to remove yarn.lock
from .nxignore
for it to work. I initially added yarn.lock
to .nxignore
because of this
Hi @SirPhemmiey, the issue you see above is caused by our parser being unable to properly prune the lock file.
In order to debug this issue, can you please create a small reproduction repo?
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
I've just run into this issue too, completely out of the blue. I can stash my current changes and it will build, unstash and I get this error building my nestjs app and generating package json.
Summary of my project:
Summary of what I know regarding the problem context:
findProjectsNpmDependencies
on line 124
dep
has a value of npm:tslib
npmDeps.dependencies
is an empty objectNot sure if I could create a reproducible given the fragiligty of this instance, however if someone wants to help me get more information about this I'm more than happy to help!
adding more context through my extremely naive debugging...
The graph.externalNodes
object is huge (expected) and has the following tslib keys:
Which makes sense why npm:tslib
is not matching
Also, options.helperDependencies
only contains npm:tslib
and nothing else
Ok, I finally reverted pnpm from 9.0.4
to 8.15.7
and everything is working again
@meeroslav Could you please look into this? I have exactly the same problem recently and it only appeared when I started using the new version of pnpm which is 9.0.4
Of course, reverting to pnpm 8.15.7
solves this problem but how about me this is only a temporary solution, because it should be fixed for v9.x as well, as this PR-17407 solved the same problem only for the v6.x version
P.S. I think that there is no need to create a reproduction repo for this, because the problem is obvious ;)
+1 can confirm, reverting to 8.15.7 solves the problem for me
Same problem here, when trying to update to pnpm 9.0.6
, the generatePackageJson=true
option + nx 17.2.8
, throws this error building the backend: "Your library compilation option specifies that the compiler external helper (tslib) is needed but it is not installed. Cannot read properties of undefined (reading 'data')"
.
I can confirm that tslib is on the dependencies list and that I performed a pnpm install
As many of you said, pnpm 8.15.7
works fine, so that's what I'm using in the meantime.
I have the same issue with yarn 1.22.
generatePackageJson:true
:Your library compilation option specifies that the compiler external helper (tslib) is needed but it is not installed.
NX Cannot read properties of undefined (reading 'data')
importHelpers
configuration which requires tslib
to be present in externalDependencies
Related https://github.com/nrwl/nx/issues/19092#issuecomment-1766229597
3.
externalDependencies
is emptyRelated https://github.com/nrwl/nx/issues/19092#issuecomment-1738821054
4.
externalDependencies
is empty because theyarn.lock
was added to.nxignore
5. Removing
yarn.lock
from.nxignore
fix the problem6.
yarn.lock
was added to.nxignore
to avoid having all projects affected when modified
It look like the chicken and the egg problem ;)
@meeroslav What do you suggest for not affecting all projects when modifying yarn.lock
but not having errors when building app-required helpers not present in external dependencies?
This is also an issue for me when trying to use pnpm
seems that there is some kind of dependency negotiation that breaks with the nx generatePackageJson
for webpack
This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! 🙏
No, this is not stale
Bumping this. Also on pnpm v9 and generatePackageJson: true. I'd like to use SWC instead of webpack but that is still not possible despite upstream nestjs supporting it (https://github.com/nrwl/nx/discussions/22632)
This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! 🙏
Not stale. Reproduction is trivial.
npm i -g pnpm@9.x && pnpx create-nx-workspace && cd whatever && pnpm i @nx/nest && nx g @nx/nest:app myapp && nx build myapp
@Clashsoft, the original issue was opened for yarn v1
not pnpm
.
The pnpm v9 support has been merged in 2 days ago and hasn't been released yet - https://github.com/nrwl/nx/pull/22906.
The fix for pnpm v9 will be rolled out in 19.2.0.
@jogelin, the generatePackageJson
(and our hasher) depends on Nx being able to parse your lock file. Otherwise there will be no external dependencies to pick from to generate package json.
If you add the lock file to .nxignore
, then parsing of the lock file will be skipped and your project graph would be incomplete (all the external nodes would be missing). This then leads to further issues, as you have experienced.
Changing the lock file is supposed to affect the entire graph, as depending on the target used each project might be affected. This doesn't mean that all those targets would be invoked, since our hasher takes care of calculating which packages influence your project (both directly via explicit import and via target executor).
Since there was no reproduction provided and the subsequent responses were unrelated to the original issue, we are closing it.
If you have an issue with package json generation or lock file pruning, please open new issue and make sure to provide reproduction or at least:
package.json
and lock filepackage.json
and pruned lock fileThank you
I am having a similar issue when upgrading to pnpm 9
NX Report complete - copy this into the issue template
Node : 20.14.0
OS : linux-x64
pnpm : 9.1.4
nx : 19.1.1
@nx/js : 19.1.1
@nx/jest : 19.1.1
@nx/linter : 19.1.1
@nx/eslint : 19.1.1
@nx/workspace : 19.1.1
@nx/cypress : 19.1.1
@nx/devkit : 19.1.1
@nx/eslint-plugin : 19.1.1
@nx/express : 19.1.1
@nx/nest : 19.1.1
@nx/next : 19.1.1
@nx/node : 19.1.1
@nx/playwright : 19.1.1
@nx/react : 19.1.1
@nx/remix : 19.1.1
@nx/storybook : 19.1.1
@nrwl/tao : 19.1.1
@nx/vite : 19.1.1
@nx/web : 19.1.1
@nx/webpack : 19.1.1
typescript : 5.4.5
---------------------------------------
Registered Plugins:
@nx/remix/plugin
---------------------------------------
Community plugins:
@compodoc/compodoc : 1.1.24
@nx-tools/nx-container : 5.3.1
@twittwer/compodoc : 1.12.0
> nx run my-nest-app:serve:development
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
HookWebpackError: Cannot read properties of undefined (reading 'data')
at makeWebpackError (/my-workspace/node_modules/.pnpm/webpack@5.91.0_@swc+core@1.5.24_@swc+helpers@0.5.11__esbuild@0.18.20/node_modules/webpack/lib/HookWebpackError.js:48:9)
at /my-workspace/node_modules/.pnpm/webpack@5.91.0_@swc+core@1.5.24_@swc+helpers@0.5.11__esbuild@0.18.20/node_modules/webpack/lib/Compilation.js:3175:12
at eval (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1)
at fn (/my-workspace/node_modules/.pnpm/webpack@5.91.0_@swc+core@1.5.24_@swc+helpers@0.5.11__esbuild@0.18.20/node_modules/webpack/lib/Compilation.js:488:17)
at _next0 (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
at eval (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
at Hook.eval [as callAsync] (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/Hook.js:18:14)
at /my-workspace/node_modules/.pnpm/webpack@5.91.0_@swc+core@1.5.24_@swc+helpers@0.5.11__esbuild@0.18.20/node_modules/webpack/lib/Compilation.js:523:46
at /my-workspace/node_modules/.pnpm/copy-webpack-plugin@10.2.4_webpack@5.91.0_@swc+core@1.5.24_@swc+helpers@0.5.11__esbuild@0.18.20_/node_modules/copy-webpack-plugin/dist/index.js:909:9
-- inner error --
TypeError: Cannot read properties of undefined (reading 'data')
at /my-workspace/node_modules/.pnpm/nx@19.1.1_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+helpers@0.5.11__@swc+types@0.1.7_typ_d6ipsl3ynuwwpvemuhs5daz6gm/node_modules/nx/src/plugins/js/package-json/create-package-json.js:124:55
at Array.forEach (<anonymous>)
at findProjectsNpmDependencies (/my-workspace/node_modules/.pnpm/nx@19.1.1_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+helpers@0.5.11__@swc+types@0.1.7_typ_d6ipsl3ynuwwpvemuhs5daz6gm/node_modules/nx/src/plugins/js/package-json/create-package-json.js:122:33)
at createPackageJson (/my-workspace/node_modules/.pnpm/nx@19.1.1_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+helpers@0.5.11__@swc+types@0.1.7_typ_d6ipsl3ynuwwpvemuhs5daz6gm/node_modules/nx/src/plugins/js/package-json/create-package-json.js:23:21)
at /my-workspace/node_modules/.pnpm/@nx+webpack@19.1.1_@babel+traverse@7.24.5_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+help_ktiouz2rcdl3zfdz4lex7hmtwi/node_modules/@nx/webpack/src/plugins/generate-package-json-plugin.js:30:64
at fn (/my-workspace/node_modules/.pnpm/webpack@5.91.0_@swc+core@1.5.24_@swc+helpers@0.5.11__esbuild@0.18.20/node_modules/webpack/lib/Compilation.js:486:10)
at _next0 (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
at eval (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
at Hook.eval [as callAsync] (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/Hook.js:18:14) {
details: 'caused by plugins in Compilation.hooks.processAssets\n' +
"TypeError: Cannot read properties of undefined (reading 'data')\n" +
' at /my-workspace/node_modules/.pnpm/nx@19.1.1_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+helpers@0.5.11__@swc+types@0.1.7_typ_d6ipsl3ynuwwpvemuhs5daz6gm/node_modules/nx/src/plugins/js/package-json/create-package-json.js:124:55\n' +
' at Array.forEach (<anonymous>)\n' +
' at findProjectsNpmDependencies (/my-workspace/node_modules/.pnpm/nx@19.1.1_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+helpers@0.5.11__@swc+types@0.1.7_typ_d6ipsl3ynuwwpvemuhs5daz6gm/node_modules/nx/src/plugins/js/package-json/create-package-json.js:122:33)\n' +
' at createPackageJson (/my-workspace/node_modules/.pnpm/nx@19.1.1_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+helpers@0.5.11__@swc+types@0.1.7_typ_d6ipsl3ynuwwpvemuhs5daz6gm/node_modules/nx/src/plugins/js/package-json/create-package-json.js:23:21)\n' +
' at /my-workspace/node_modules/.pnpm/@nx+webpack@19.1.1_@babel+traverse@7.24.5_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+help_ktiouz2rcdl3zfdz4lex7hmtwi/node_modules/@nx/webpack/src/plugins/generate-package-json-plugin.js:30:64\n' +
' at fn (/my-workspace/node_modules/.pnpm/webpack@5.91.0_@swc+core@1.5.24_@swc+helpers@0.5.11__esbuild@0.18.20/node_modules/webpack/lib/Compilation.js:486:10)\n' +
' at _next0 (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)\n' +
' at eval (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)\n' +
' at Hook.eval [as callAsync] (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)\n' +
' at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/Hook.js:18:14)',
module: undefined,
loc: undefined,
hideStack: true,
chunk: undefined,
file: undefined,
hook: 'Compilation.hooks.processAssets',
error: TypeError: Cannot read properties of undefined (reading 'data')
at /my-workspace/node_modules/.pnpm/nx@19.1.1_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+helpers@0.5.11__@swc+types@0.1.7_typ_d6ipsl3ynuwwpvemuhs5daz6gm/node_modules/nx/src/plugins/js/package-json/create-package-json.js:124:55
at Array.forEach (<anonymous>)
at findProjectsNpmDependencies (/my-workspace/node_modules/.pnpm/nx@19.1.1_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+helpers@0.5.11__@swc+types@0.1.7_typ_d6ipsl3ynuwwpvemuhs5daz6gm/node_modules/nx/src/plugins/js/package-json/create-package-json.js:122:33)
at createPackageJson (/my-workspace/node_modules/.pnpm/nx@19.1.1_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+helpers@0.5.11__@swc+types@0.1.7_typ_d6ipsl3ynuwwpvemuhs5daz6gm/node_modules/nx/src/plugins/js/package-json/create-package-json.js:23:21)
at /my-workspace/node_modules/.pnpm/@nx+webpack@19.1.1_@babel+traverse@7.24.5_@swc-node+register@1.9.1_@swc+core@1.5.24_@swc+help_ktiouz2rcdl3zfdz4lex7hmtwi/node_modules/@nx/webpack/src/plugins/generate-package-json-plugin.js:30:64
at fn (/my-workspace/node_modules/.pnpm/webpack@5.91.0_@swc+core@1.5.24_@swc+helpers@0.5.11__esbuild@0.18.20/node_modules/webpack/lib/Compilation.js:486:10)
at _next0 (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:11:1)
at eval (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
at Hook.eval [as callAsync] (eval at create (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/my-workspace/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/Hook.js:18:14)
}
Node.js v20.14.0
is there anything im missing?
i can try to create a reproduction as well
@lwhiteley I think it should be ok with the future v19.2 of Nx:
Maybe you should try beta ~19.2.0-beta.5
: nx migrate 19.2.0-beta.5
to know if the v19.2 is fixing it ;)
Thanks for pointing that out @jogelin
you're a lifesaver!
i can confirm the fix works
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
When using
yarn
as package manager and trying to build a project that contains "generatePackageJson": true option, build target is failingExpected Behavior
It should build
GitHub Repo
No response
Steps to Reproduce
generatePackageJson
in your target build project.jsonyarn build <project>
Nx Report
Failure Logs
Package Manager Version
1.22.19
Operating System
Additional Information
It's the same issue as this: https://github.com/nrwl/nx/issues/17450