NPM is not defined on the PATH when running using: "node"
#2037
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.
Uh oh!
There was an error while loading. Please reload this page.
-
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
azure-functions-core-tools, but looks like the NPM is not defined to PATH when using NodeJS runtime.Custom Action using NodeJS runtime
Install call using
@actions/execReceived error:
Is this correct for custom actions that run using NodeJS? The NodeJS should be automatically defined to PATH. (Or not?)
The workaround is to define a custom action to use
using: compositeand do a pure call to NodeJS (node ./dist/index.js) passing all inputs usingenv(INPUT_ABC: abc) and after install the Node through@actions/tool-cache, but this sounds stranger because I'm using a NodeJS custom actions to install NodeJS. 🤔Beta Was this translation helpful? Give feedback.
All reactions