You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When run following scripts using node.js v20 or v22:
const { AIAgent, ClaudeChatModel, ExecutionEngine } = require('@aigne/core')
const model = new ClaudeChatModel({
apiKey: process.env.ANTHROPIC_API_KEY,
model: 'claude-3-5-sonnet-latest'
})
const engine = new ExecutionEngine({ model })
const agent = AIAgent.from({
instructions: `\
You are a product analyst. Extract and summarize the key features of the product.
Product description:
{{product}}`,
outputKey: 'features'
})
engine
.call(agent, {
product: 'AIGNE is a No-code Generative AI Apps Engine'
})
.then(result => {
console.log(result)
})
.catch(error => {
console.error(error)
})
Observed Behavior
undefined
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/wangshijun/Develop/blocklet/aigne-code-reviewer/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]_/node_modules/@aigne/core/lib/cjs/index.js from /Users/wangshijun/Develop/blocklet/aigne-code-reviewer/poc.js not supported.
index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/wangshijun/Develop/blocklet/aigne-code-reviewer/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]_/node_modules/@aigne/core/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at Object.<anonymous> (/Users/wangshijun/Develop/blocklet/aigne-code-reviewer/poc.js:1:55) {
code: 'ERR_REQUIRE_ESM'
}
Expected Behavior
Should run as expected
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
RT
Reproduction Steps
When run following scripts using node.js v20 or v22:
Observed Behavior
Expected Behavior
Should run as expected
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: