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.

core: ./core is not exported in package.json

See original GitHub issue

What is the problem?

When migrating to cdk 2.1.0, i have the following error:

Error: Package subpath ‘./core’ is not defined by “exports” in /…/node_modules/aws-cdk-lib/package.json

(and actually, it is not in the package.json)

Reproduction Steps

In my code:

import { CfnOutput, SecretValue, Stage, Stack } from 'aws-cdk-lib/core';

Use cdk 2.1.0 in package.json:

"devDependencies": {
    "aws-cdk": "2.1.0",
  },
  "dependencies": {
    "aws-cdk-lib": "2.1.0",
    "constructs": "10.0.12",
  }

Then try to synthesise:

cdk synth

Gives the error:

Error: Package subpath ‘./core’ is not defined by “exports” in /…/node_modules/aws-cdk-lib/package.json

What did you expect to happen?

I expected to have get the template synthesised.

What actually happened?

The following error (line 18 is the import statement above):

Error: Package subpath ‘./core’ is not defined by “exports” in /…/node_modules/aws-cdk-lib/package.json at new NodeError (node:internal/errors:371:5) at throwExportsNotFound (node:internal/modules/esm/resolve:416:9) at packageExportsResolve (node:internal/modules/esm/resolve:669:3) at resolveExports (node:internal/modules/cjs/loader:482:36) at Function.Module._findPath (node:internal/modules/cjs/loader:522:31) at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:999:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (/…/bin/mycode.ts:18:1)

CDK CLI Version

2.1.0

Framework Version

No response

Node.js Version

v17.0.1

OS

mac OS BigSur (M1)

Language

Typescript

Language Version

TypeScript 4.5.2

Other information

Manually adding “./core”: “./core/index.js” to the node_modules/aws-cdk-lib/package.json solve the issue, but this is not a viable solution.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

22reactions
ryparkercommented, Dec 10, 2021

In CDK v2 all @aws-cdk/core exports are now direct exports of aws-cdk-lib

The following should work: import { CfnOutput, SecretValue, Stage, Stack } from 'aws-cdk-lib';

19reactions
JoshuaTothcommented, Dec 13, 2021

@ryparker 's fix works fine

aws-cdk-lib/core -> aws-cdk-lib

Edit* adding more info

import * as cdk from 'aws-cdk-lib/core'

to

import * as cdk from 'aws-cdk-lib'
Read more comments on GitHub >

github_iconTop Results From Across the Web

Chart v4 : Module not found: Error: Package path . is not ...
I looked at node_modules/chart. js/package. json file and there is a well defined set of exports there.
Read more >
Configuring Jest
The configuration file should simply export an object: JavaScript; TypeScript ... Node.js core modules, like fs , are not mocked by default.
Read more >
module not found: error: package path . is not exported from ...
json ) I imported using the following code: import uuidv4 from 'uuid/v4'; node.js. reactjs. There are no ads here – enjoy ✨. Help...
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
The imported JSON only exposes a default export. There is no support for named exports. A cache entry is created in the CommonJS...
Read more >
Package exports - webpack
The exports field in the package.json of a package allows to declare which module should be used when using module requests like import...
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