You can import public npm (JavaScript) and PyPI (Python) packages in your Code by Zapier steps. This allows you to use community-tested libraries for tasks like parsing documents, transforming data, advanced date manipulation, and more.
This feature is rolling out to accounts in phases. If you don't have access yet, it will be available soon.
Code by Zapier is an advanced feature.
- If you're not familiar with JavaScript or Python, ask a developer for help.
- Contact Support based on your plan for help with how Code by Zapier processes code only. Zapier does not provide support for writing, debugging, or troubleshooting code.
- For more help, visit the Zapier Community's Code resources.
Prerequisites
- You need to know the package name you want to use.
- The package must be publicly available on npm (for JavaScript) or PyPI (for Python).
Your responsibilities
Because you're selecting which third-party packages to use in Code by Zapier (if any), this feature is provided "as-is", with no additional warranty or support beyond what is already included for Code by Zapier.
When using third-party packages, you (and not Zapier) are responsible for:
- Selecting packages. Zapier does not provide legal review, code review, or security vetting of third-party packages. Selecting unsuitable code could have undesired or otherwise negative impacts on your workflows, which Zapier is not responsible for.
- Reviewing licenses. Review and comply with the license and terms of any packages you choose to use.
- Troubleshooting. Zapier Support cannot help debug code that uses third-party packages. Refer to the package's documentation for help.
- Security. Packages run with the same permissions as your code. Avoid packages from unknown or untrusted sources.
- Ongoing maintenance. Packages may become deprecated or develop vulnerabilities. You are responsible for monitoring and updating your packages as needed.
Treat packages as third-party software you choose to run in your own environment, subject to each package's license and security posture.
Add a package to your Code step
1. Add the package
In your Code step, in the Code editor:
- Click the Packages icon on the left sidebar.
- Click Update Code.
- Click Add new package.
- In the Package name field, enter the name of the package you want to use. The name is case-sensitive.
- (Optional) In the Package version field, enter a specific version number. If left blank, the latest version is used.
- Click Save.
2. Import and use the package in your code
- Next to your package, click the Copy icon to copy the import statement.
- Paste it in the Code editor.
For JavaScript, your code must use the export default async function main() wrapper. Code by Zapier adds it automatically when you add a package. For Python, no special wrapper is required.
Edit a package
You can change the package name or version. Editing the version is often the most useful, for example to pin a specific version or fix compatibility issues.
In your Code step, in the Code editor:
- Next to your package, click the more icon .
- In the dropdown menu, click Edit package.
- Edit the package name or version as needed.
- Click Save.
Limitations
- Package install and code execution have separate time limits per run. Execution time limits vary by plan. Install time limits are 120 seconds for Enterprise and 30 seconds for all other paid plans. Memory is limited to 512 MB of RAM across all plans.
- Only ESM (ECMAScript Module) JavaScript packages are supported. Packages that use only CommonJS (CJS) will not work.
- Native modules are not supported. Packages that require compiled binaries or native system modules will not work. If you try to use an unsupported package, you'll receive an error message.
- Private registries are not supported. You can only use packages from the public npm and PyPI registries.
- Package size affects performance. Large packages may increase installation time and could cause timeouts. If you experience timeouts, try using a smaller or more focused package.
- Zapier does not scan packages for security vulnerabilities. Review the package's security posture before using it.
Troubleshooting
Any errors thrown by a package during installation or execution are surfaced in your Zap history, the same way other Code by Zapier errors appear. Review your Zap history to diagnose package-related issues.
Unsupported package error
Some packages are not compatible with the Code by Zapier environment:
- Packages requiring native binaries or system-level access will not work.
- Try finding an alternative package that provides similar functionality without native dependencies.
Timeout during package installation
Large packages may take longer to install:
- Consider using a smaller, more focused package.
- If possible, import only the specific functions you need rather than the entire package.