Hi! I have searched for problems calling installed dependencies, but I’m unable to figure out why I’m getting “Shippo is not a constructor” error. Any help is appreciated. Details of error at the end.
Code from index.js:
export const code = async (inputs) => {
// Import the Shippo module using require
const Shippo = require(‘shippo’);
const shippo = new Shippo(‘shippo_live_123456789’);
Code from package.json
{
“dependencies”: {
“shippo”: “2.2.5”
}
}
Error:
---------error-------
{“stack”:“TypeError: Shippo is not a constructor\n at Object.code (/usr/src/app/dist/packages/server/api/sandbox/0/codes/step_5/index.js:7:20)\n at Object. (webpack://activepieces/engine/src/lib/core/code/no-op-code-sandbox.ts:8:27)\n at Generator.next ()\n at (webpack://activepieces/node_modules/tslib/tslib.es6.mjs:121:69)\n at new Promise ()\n at Module.m (webpack://activepieces/node_modules/tslib/tslib.es6.mjs:117:10)\n at Object.runCodeModule (/usr/src/app/dist/packages/server/api/sandbox/0/main.js:1:524325)\n at (webpack://activepieces/engine/src/lib/handler/code-executor.ts:44:42)\n at Generator.next ()\n at a (webpack://activepieces/node_modules/tslib/tslib.es6.mjs:118:56)”,“message”:“Shippo is not a constructor”}
Thank you for your swift response! I can get this working in a standalone script, and in Google Apps Script, but not in Active Pieces. I tried this way from npm (thanks again for the input), from Shippo docs, and a number of other ways that seemed logical for me, with other ideas from the latest ChatGPT, Claude, Mistral, and Gemini models. I tried different npm dependency versions, listed package.json, and invoked dependencies directly in the code.
I’m not saying it’s impossible, but the above are the things I tried. I’m still interested in learning if you or anyone figures it out, though. My current workaround, and one I use often when Pieces are lacking and the code piece won’t work with me: Use Active Pieces to send to Google Sheets and set Apps Script to run on change or edit. I just have better first-pass luck in that system.