(@aws-cdk/aws-cognito): import 'punycode/'
See original GitHub issue❓ General Issue
The Question
about “@aws-cdk/aws-cognito/lib/user-pool.ts”. I don’t think punycode’s trailing slash is necessary.
current code
import { toASCII as punycodeEncode } from 'punycode/';
expected code
import { toASCII as punycodeEncode } from 'punycode';
Environment
- CDK CLI Version: v1.100.0
- Module Version:
- Node.js Version:
- OS:
- Language (Version):
Other information
An error occurred when importing ‘@aws-cdk/aws-cognito’ in the Lambda function handler.
Lambda Runtime Error
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'punycode/'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
...
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
punycode - npm
A robust Punycode converter that fully complies to RFC 3492 and RFC 5891, and works on nearly all JavaScript platforms.
Read more >Punycode | Node.js v19.3.0 Documentation
Punycode is a character encoding scheme defined by RFC 3492 that is primarily intended for use in Internationalized Domain Names. Because host names...
Read more >punycode is deprecated in npm - what should I replace it with?
I'm using the npm module punycode in my Angular project. ... Try import punycode from "punycode/"; for example.
Read more >What is the Punycode in Node.js ? - GeeksforGeeks
Punycode is a special encoding syntax that is specifically used to convert Unicode characters (UTF-8) to ASCII, which is nothing but the ...
Read more >Working with IDN domains and Punycode in JavaScript
A tool that converts a text with special characters (Unicode) to the Punycode encoding (just ASCII). Used for internationalized domain names (IDN).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had this error as well and was able to fix it through some code changes. For me it was an error in my code organisation.
In my case it was to do with mixing devDependencies/cdk code with my runtime lambda code.
e.g. I had some files similar to:
package.json
users/index.ts
users/construct.ts
api/construct.ts
including that
users/index.ts
file as an entry therefore included theusers/construct.ts
which tried to include some cdk cognito code which wasn’t part of my runtime dependencies.So the fix was to make sure my construct/cdk code was completely separate from my runtime lambda code.
Thanks for posting this @danielholmes, I had the same issue.
We had some Custom::Trigger that would run to populate user data on deploy. Unfortunately, the lambda handler was thrown in the same module as some CDK code that was loosely related. This caused esbuild to bundle
aws-cdk-lib/aws-cognito
in the lambda, which declares a ‘bundledDependency’ on ‘punycode/’, but apparently it isn’t bundled in the cdk v2 library (hence the require).This popped up on upgrade to CDK v2 after working with CDK v1 with an error like
Runtime.ImportModuleError: Error: Cannot find module 'punycode/'
.The answer for me was to isolate the lambda code so that NO CDK code was referenced (even transitively) by module imports.