Running cdk deploy
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.
at Module._compile (internal/modules/cjs/loader.js:1144:30)
This is :bug: Bug Report
I've got the same with TS(v.1.27) but it happens only when I've tried to run it by npm. a workaround that works for me is to run it globally.
npm version: 6.13.4
framework version: 1.27
os: linux
language: typescript
Same error with node version 13.3
With node version 12.16.1 (LTS), the error is gone. Everything works fine.
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 !
Had the same with
npm version: 6.13.4
framework version 1.27 & 1.26
os: WSL
language: Java
Looks like it works with npm 6.13.6 (node v13.7.0)
Adding "yaml": "1.7.2" to my package.json and running npm i solved it for me
I am getting the same error when runing cdk init --language typescript
Error: Package exports for '/usr/local/lib/node_modules/cdk/node_modules/yaml' do not define a valid './types' target
at resolveExportsTarget (internal/modules/cjs/loader.js:545:13)
at applyExports (internal/modules/cjs/loader.js:459:14)
at resolveExports (internal/modules/cjs/loader.js:508:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:577:20)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:879:27)
at Function.Module._load (internal/modules/cjs/loader.js:785:27)
at Module.require (internal/modules/cjs/loader.js:956:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/usr/local/lib/node_modules/cdk/node_modules/aws-cdk/lib/serialize.ts:5:19)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
Update:
It got worked for me after updating node to 13.10.1 and npm 6.13.7
Suspected as P0, needs investigation
@npxcomplete Can you paste the output of a couple of things for me
1: cdk --version
2: cdk deploy --verbose
I suspect a version mismatch somewhere.
remember to redact any sensitive information that may be in this output
Same issue here after upgrading.
$ cdk --version
1.19.0 (build 5597bbe)
$ npm upgrade
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ New minor version of npm available! 6.13.4 โ 6.14.2 โ
โ Changelog: https://github.com/npm/cli/releases/tag/v6.14.2 โ
โ Run npm install -g npm to update! โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
$ npm install -g npm
+ [email protected]
$ npm install -g aws-cdk
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
/usr/local/bin/cdk -> /usr/local/lib/node_modules/aws-cdk/bin/cdk
+ [email protected]
added 234 packages from 227 contributors in 9.41s
$ cdk --version
Error: Package exports for '/usr/local/lib/node_modules/aws-cdk/node_modules/yaml' do not define a valid './types' target
at resolveExportsTarget (internal/modules/cjs/loader.js:614:9)
at applyExports (internal/modules/cjs/loader.js:499:14)
at resolveExports (internal/modules/cjs/loader.js:548:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:650:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:948:27)
at Function.Module._load (internal/modules/cjs/loader.js:854:27)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/usr/local/lib/node_modules/aws-cdk/lib/serialize.ts:5:19)
at Module._compile (internal/modules/cjs/loader.js:1128:30)
@deki I'm not able to reproduce this. Tried across multiple versions of node/npm.
It looks like everyone reporting issues here is using their system's global NodeJS installation, since error dir is reported as /usr/local/lib/node_modules/aws-cdk/node_modules. I'm not sure why that would be causing issues here, but its commonly the source of permission problems.
Some debugging tips:
node_modules directory and reinstall aws-cdk, does the issue persist?aws-cdk from your project's local node_modules dir, does the issue persist?nvm and use a user level install of Node/Npm, does the issue persist?We recommend using nvm generally speaking because it helps avoid a lot of similar issues.
Worked for me after upgrading from node 13.1.0 to node 13.10.1.
@MrArnoldPalmer I am using NVM and it works for me on Node 13.7.0 and fails on 13.5.0
Worked after upgrade from node 13.6.0 to 13.10.1, npm 6.13.7
@liamor thanks, that pointed me in the right direction.
It looks like there is an issue with the yaml dependency and the exports key, 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 the types module in yaml.
Here is the issue in the yaml repo with more info https://github.com/eemeli/yaml/issues/140
Bumping the yaml version dependency should fix this issue, this will be in the next release.
https://github.com/aws/aws-cdk/pull/6670