Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPM dependencies for local triggers are not installed #47

Open
birjj opened this issue Feb 8, 2024 · 1 comment
Open

NPM dependencies for local triggers are not installed #47

birjj opened this issue Feb 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@birjj
Copy link

birjj commented Feb 8, 2024

Description

When using local triggers, the trigger's dependencies (defined in triggers/<trigger-name>/package.json) aren't installed when running Actionsflow as an action.

As a result the "Run Actionsflow" step fails with

Error: Error: Cannot find module '<dependency-name>'
Require stack:
- /home/runner/work/actionsflow-automation/actionsflow-automation/triggers/<trigger-name>/index.js
- /home/runner/work/_actions/actionsflow/actionsflow-action/v1.3.0/dist/main/index.js

Steps to reproduce

See my demo repo.

Alternatively, create a local trigger yourself:

  1. Create a triggers/foobar/ directory
  2. Navigate into it and run npm init && npm install cheerio
  3. Create an index.js file containing const { load } = require("cheerio");
  4. Add the foobar trigger to one of your workflows
  5. Run Actionsflow using the default GitHub Action

Expected result

The trigger dependencies should be installed, and the trigger should execute.

Actual result

The trigger dependencies were not installed, so the trigger failed with Error: Cannot find module '<dependency-name>'

@birjj birjj added the bug Something isn't working label Feb 8, 2024
@birjj
Copy link
Author

birjj commented Feb 8, 2024

As a workaround, it looks like adding the dependency to the root NPM module (package.json instead of triggers/<trigger-name>/package.json) and setting using: "local" resolves this, seeing as actionsflow-action runs npm install when using === "local".

This of course breaks with the contained nature of packages, and requires using: "local", so it isn't a long-term solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant