aws-cdk: yaml do not define a valid './types' target
Running cdk deploy
Error Log
Error: Package exports for ‘C:\Users\kpratt\AppData\Roaming\npm\node_modules\aws-cdk\node_modules\yaml’ do not define a valid ‘./types’ target at resolveExportsTarget (internal/modules/cjs/loader.js:621:9) at applyExports (internal/modules/cjs/loader.js:502:14) at resolveExports (internal/modules/cjs/loader.js:551:12) at Function.Module._findPath (internal/modules/cjs/loader.js:657:22) at Function.Module._resolveFilename (internal/modules/cjs/loader.js:960:27) at Function.Module._load (internal/modules/cjs/loader.js:855:27) at Module.require (internal/modules/cjs/loader.js:1033:19) at require (internal/modules/cjs/helpers.js:72:18) at Object.<anonymous> (C:\Users\kpratt\AppData\Roaming\npm\node_modules\aws-cdk\lib\serialize.ts:5:19) at Module._compile (internal/modules/cjs/loader.js:1144:30)
Environment
- CLI Version : 6.13.4
- Framework Version: 1.26 & 1.27
- OS : Windows
- Language : Java
Other
This is 🐛 Bug Report
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 12
- Comments: 15 (6 by maintainers)
@liamor thanks, that pointed me in the right direction.
It looks like there is an issue with the
yamldependency and theexportskey, which is used for ESM module support. This occurs on CDK versions going back quite a ways.If you need to use cdk with NodeJS 13.0.0-13.6.0, you can use the --experimental-modules flag, ie:
node --experimental-modules /path/to/cdk --version. Otherwise, I’d recommend using node 12 or > 13.7.0 until we figure out the best course here. It doesn’t seem like we can change our export strategy currently since the top level CJS export doesn’t expose thetypesmodule in yaml.Here is the issue in the yaml repo with more info https://github.com/eemeli/yaml/issues/140
I am getting the same error when runing
cdk init --language typescriptUpdate:
It got worked for me after updating node to 13.10.1 and npm 6.13.7
I get the same error with npm: ‘6.13.2’ MAC OS: 10.14.6
ps …
looks like it is something todo with yaml module. I replaced the “yaml” module “/node_modules/aws-cdk/node_modules/yaml” with version “1.7.2” and it worked !