question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

yaml do not define a valid './types' target

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
MrArnoldPalmercommented, Mar 11, 2020

@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

1reaction
rahulrkr08commented, Mar 9, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Package exports for tslib do not define a valid '.' target
I had a similar issue and I workarounded by downgrading node version (from v13.0.1 to v12.19.0). It's probably not the ideal solution, ...
Read more >
package exports for do not define a valid '.' target
When a package exports a value or a type, we need to explicitly add export statement for it in the declaration file. The...
Read more >
YAML
yaml is a definitive library for YAML, the human friendly data serialization standard. This library: Supports both YAML 1.1 and YAML 1.2 and...
Read more >
does not provide an export named 'default - You.com | The AI ...
Try to use the ESM module system instead of CommonJS in its tsconfig. json . That means that the package has no export...
Read more >
Package exports for ~ do not define a valid '.' target の解決方法 ...
Error: Package exports for ~ do not define a valid '.' target の解決方法について書きます。 目次. エラーが起きるまで; エラーコード; エラーの ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found