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
Using JSII to compile a TS/JS library into Python, and importing the library into a Python CDK application is failing when attempting to run any cdk commands.
The failure response returned is:
jsii.errors.JavaScriptError:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /var/folders/gz/.../T/jsii-kernel-ku2ecO/node_modules/<library_name>/package.json
as well as various exports of each sub-package similar to aws-cdk-lib like so
Expected Behavior
I expect cdk synth to synthesize the Python CDK code into a CloudFormation template by compiling/processing the Javascript artifact through the Python interface.
Current Behavior
When using the JSII translated library in Python, the Interfaces are all read correctly.
However, at the time of compiling the Javascript package when running cdk commands... the compilation fails with the error message
jsii.errors.JavaScriptError:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /var/folders/gz/.../T/jsii-kernel-ku2ecO/node_modules/<library-name>/package.json
at new NodeError (node:internal/errors:405:5)
at exportsNotFound (node:internal/modules/esm/resolve:259:10)
at packageExportsResolve (node:internal/modules/esm/resolve:533:13)
at resolveExports (node:internal/modules/cjs/loader:571:36)
at Module._findPath (node:internal/modules/cjs/loader:645:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1058:27)
at Function.resolve (node:internal/modules/helpers:127:19)
at Kernel._Kernel_load (/private/var/folders/gz/zv011yyj62qd1rkfkx54q5zh0000gq/T/tmpqrzgy3_p/lib/program.js:10002:83)
at /private/var/folders/gz/zv011yyj62qd1rkfkx54q5zh0000gq/T/tmpqrzgy3_p/lib/program.js:9722:181
at Kernel._Kernel_debugTime (/private/var/folders/gz/zv011yyj62qd1rkfkx54q5zh0000gq/T/tmpqrzgy3_p/lib/program.js:10434:24)
Compile library package into Python using jsii-pacmak
Import Library into Python CDK Application
mkdir python-test-app && cd python-test-app
cdk init app --language python
Install library and import into app.py with the code
importlibrary_nameasfoo
Run cdk synth
Possible Solution
The main suspect is the package.json file, as the error clearly mentions it not containing "exports" main.
There is nothing within our pacakge.json that seems to be incorrect or misaligned from other libraries.
Additional Information/Context
For security purposes, I have not included the full contents of any file. Please follow up with any questions regarding files for information.
This library has been confirmed to work for TS and Go applications, however has not worked for Python.
Describe the bug
Using JSII to compile a TS/JS library into Python, and importing the library into a Python CDK application is failing when attempting to run any
cdk
commands.The failure response returned is:
The Library Package is created using
The package.json contains
as well as various exports of each sub-package similar to aws-cdk-lib like so
Expected Behavior
I expect
cdk synth
to synthesize the Python CDK code into a CloudFormation template by compiling/processing the Javascript artifact through the Python interface.Current Behavior
When using the JSII translated library in Python, the Interfaces are all read correctly.
However, at the time of compiling the Javascript package when running
cdk
commands... the compilation fails with the error messageReproduction Steps
Create CDK Construct Library Using JSII
Import Library into Python CDK Application
mkdir python-test-app
&&cd python-test-app
cdk init app --language python
cdk synth
Possible Solution
The main suspect is the package.json file, as the error clearly mentions it not containing
"exports" main
.There is nothing within our pacakge.json that seems to be incorrect or misaligned from other libraries.
Additional Information/Context
For security purposes, I have not included the full contents of any file. Please follow up with any questions regarding files for information.
This library has been confirmed to work for TS and Go applications, however has not worked for Python.
SDK version used
"jsii": "~5.0.0","jsii-pacmak": "^1.83.0","aws-cdk-lib": "2.92.0", "constructs": "10.1.243","typescript": "^5.1.3"
Environment details (OS name and version, etc.)
Mac on Venture. Python Versions 3.7, 3.8, 3.10, 3.11 using venv
The text was updated successfully, but these errors were encountered: