NPM is not defined on the PATH when running using: "node"
#2037
-
|
This is a question about the expected behavior when using JavaScript Custom Actions. I have a custom Action that runs using NodeJS and needs to install another CLI tool at the runtime, like Custom Action using NodeJS runtimeruns:
using: "node16"
main: "dist/index.js"Install call using
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
This is expected for JavaScript actions When you use: runs:
using: "node16"
main: "dist/index.js"the runner invokes the Node.js binary for the action, but it does not guarantee that For normal JS dependencies, the recommended approach is to install them during development/CI and bundle the action, for example with npm ci
npx @vercel/ncc build index.js -o distThen commit the generated If your action really needs to install or call an external CLI at runtime, a composite action is probably a better fit, because you can explicitly prepare the environment first: runs:
using: "composite"
steps:
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm install --location=global azure-functions-core-tools@4
shell: bash
- run: node ./dist/index.js
shell: bashSo in short: |
Beta Was this translation helpful? Give feedback.
This is expected for JavaScript actions
When you use:
the runner invokes the Node.js binary for the action, but it does not guarantee that
npmis available onPATH. JavaScript actions are generally expected to be packaged/self-contained, with their dependencies bundled intodist/at build timeFor normal JS dependencies, the recommended approach is to install them during development/CI and bundle the action, for example with
@vercel/ncc:Then commit the generated
dist/file.If your action really needs to install or call an external CLI at runtime, a composite action is probably a better fit, bec…