generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
0.1.1
Node.js Version
22.13.0
Operating System
macOS 26.1
Installation Method
npm
Steps to Reproduce
- Create a new Node.js project without
"type": "module"in package.json (CommonJS project) - Install Strands SDK:
npm install @strands-agents/sdk - Create a TypeScript file that imports the SDK:
import * as st from "@strands-agents/sdk" - Try to run with tsx:
npx tsx src/server.ts - See error:
ERR_PACKAGE_PATH_NOT_EXPORTED: No "exports" main defined
Minimal reproducible example:
package.json:
{
"name": "test-strands",
"version": "1.0.0",
"dependencies": {
"@strands-agents/sdk": "^0.1.1"
},
"devDependencies": {
"tsx": "^4.21.0"
}
}main.ts
import * as st from "@strands-agents/sdk";
console.log("SDK imported successfully");Run npx tsx src/test.ts
Expected Behavior
The SDK should be importable in both CommonJS and ES Module projects without requiring users to modify their project configuration to "type": "module"
Actual Behavior
Import fails with error:
[ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /path/to/node_modules/@strands-agents/sdk/package.json
Additional Context
The issue occurs because the SDK's package.json exports configuration only defines "import" paths but not "require" paths for CommonJS compatibility:
"exports": {
".": {
"import": "./dist/src/index.js",
"types": "./dist/src/index.d.ts"
}
}This makes the SDK incompatible with CommonJS projects, which is a common setup for many Node.js applications.
Possible Solution
Add CommonJS support to the exports configuration in package.json:
"exports": {
".": {
"import": "./dist/src/index.js",
"require": "./dist/src/index.js",
"types": "./dist/src/index.d.ts"
},
"./openai": {
"import": "./dist/src/models/openai.js",
"require": "./dist/src/models/openai.js",
"types": "./dist/src/models/openai.d.ts"
}
// ... etc
}Related Issues
No response
jospas
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working