After upgrading from 1.15.0 to 1.16.1, cdk synth
command fails with:
Error: ENOENT: no such file or directory, symlink '../fast-xml-parser/cli.js' -> 'cdk.out/asset.046889af674a59f8c3e80adeeadca2bd0a4922e131160a62c280be1c0d15a097/node_modules/.bin/xml2js'
fast-xml-parser
is a dependency I have under lib/resources/package.json
used by a lambda function.
Any idea where those symlinks come from or what creates them? And how to clean them / regenerate them.
Also running cdk synth
and then cdk diff
again seems to remove the issue and diff says No differences
. But I have same issue running jest
for the tests for the lambda (same missing symlink warning). If I revert back to 1.15.0, both work.
Error: ENOENT: no such file or directory, symlink '../fast-xml-parser/cli.js' -> 'cdk.out/asset.046889af674a59f8c3e80adeeadca2bd0a4922e131160a62c280be1c0d15a097/node_modules/.bin/xml2js'
at Object.symlinkSync (fs.js:909:3)
at Object.copyDirectory (/home/vertti/dev/kesko/k-ruoka-product-service/importers/ttp-importer/node_modules/@aws-cdk/assets/lib/fs/copy.ts:25:14)
at Staging.synthesize (/home/vertti/dev/kesko/k-ruoka-product-service/importers/ttp-importer/node_modules/@aws-cdk/assets/lib/staging.ts:87:7)
at Function.synth (/home/vertti/dev/kesko/k-ruoka-product-service/importers/ttp-importer/node_modules/@aws-cdk/core/lib/construct.ts:56:28)
at App.synth (/home/vertti/dev/kesko/k-ruoka-product-service/importers/ttp-importer/node_modules/@aws-cdk/core/lib/app.ts:142:36)
at process.App.process.once (/home/vertti/dev/kesko/k-ruoka-product-service/importers/ttp-importer/node_modules/@aws-cdk/core/lib/app.ts:121:45)
at Object.onceWrapper (events.js:286:20)
at process.emit (events.js:198:13)
at process.EventEmitter.emit (domain.js:448:20)
at process.emit (/home/vertti/dev/kesko/k-ruoka-product-service/importers/ttp-importer/node_modules/source-map-support/source-map-support.js:485:21)
Getting the same here.
I suspect is something related to yarn workspaces
and their links. Are you using it?
I'm seeing the same problem with a TypeScript Lambda (compiled to JavaScript) which has these dependencies installed with regular npm install:
"dependencies": {
"@aws/dynamodb-data-mapper": "^0.7.3",
"@aws/dynamodb-data-mapper-annotations": "^0.7.3",
"node-fetch": "^2.3.0",
"uuid": "^3.3.2"
}
Problems are caused uuid, which sets up a symlink as .bin/uuid => ../uuid/bin/uuid. When I delete the symlink manually, deployment works.
Also noteworthy that after a failed attempt, AWS CDK leaves an incomplete cdk.out/asset.xxx folder there. Next time you run it, deployment succeeds, but the folder doesn't contain node_modules, so the deployed Lambda function doesn't actually work.
same problem here but after installing the lambda dependencies with npm install --no-bin-links
then deployment works.
Suspected as p0 so tagging as such
@sousandrei Nope, plain npm.
@kennu my typescript lambdas have just these deps:
"dependencies": {
"adm-zip": "0.4.13",
"fast-xml-parser": "3.14.0",
"lodash": "4.17.15"
}
@hanstf is probably correct as my error message also references the cli.js which is that packages bin
.
I have this same issue, the package causing issues is detect-libc
.
I am running on a Linux container image but the project/stack directory and node_modules reside on a Windows host mounted volume. The error is related to symlinks which can be a bit funky under Windows, I imagine this is related.
repro-ing the issue
confirmed that this is an issue as of 1.16.0
- assets are failing to include and stage symlinks
repro steps in TypeScript:
lambda
folder in a project with a handlerpath-to-node_modules
path-to-lambda
const hello = new lambda.Function(this, 'HelloHandler', {
runtime: lambda.Runtime.NODEJS_10_X,
code: lambda.Code.asset('lambda'),
handler: 'hello.handler'
});
Until 1.15.0
This used to yield a staged asset that included node_modules
along with the handler on a cdk synth
command
As of 1.16.0
This fails to resolve with
Error: ENOENT: no such file or directory, symlink '
looking into a fix
seems like the issue was introduced in #4473
@nmussy any ideas?
Reverting it for now - #5022
I know its late on a friday, but any chance there could be a 1.16.3 release cut with this fix?
In case anyone else sees this, just add the following to your package.json
"resolutions": {
"@aws-cdk/assets": "1.15.0",
"@aws-cdk/core": "^1.16.0",
"@aws-cdk/cx-api": "^1.16.0"
}
If you have a mono-repo, place it in the root
Most helpful comment
same problem here but after installing the lambda dependencies with
npm install --no-bin-links
then deployment works.