jonnyzzz / TeamCity.Node

Node.js, NPM and Phantom.JS runners for TeamCity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm: command not found after node.js was installed

Bluejanis opened this issue · comments

I am getting an error "npm: command not found" when running npm install, even though node-js was installed in the first build step.
I am using TeamCity Professional 2021.1.1 (build 92714)

The error:

[npm install] /opt/buildagent/temp/agentTmp/wrapper157115028716706048.sh: line 2: npm: command not found
[Step 2/6] Process exited with code 127

More context:

image

Same here, builds were working in an older versions of TeamCity but after updating to 2021.2 (build 99542) the same error happened to us.

Di you found any solution?

hey @Bluejanis @mlorenzog did either of you ever find a solution?

I'm seeing pretty much the same kind of error, when I install a node version with the plugin it is ignored by subsequent steps.

@jonnyzzz is this plugin still actively worked on?

The native alternative, Node.js metarunner, didn't work on my case because or agents are already dockers.
Instead we made it work by installing NVM in our agents and add this at the start of the command line step:

. ~/.nvm/nvm.sh
nvm use $NODE_VERSION || nvm install $NODE_VERSION

It's not an ideal solution, but it gets the work done

That's what we did, but instead of bundling a specific NPM version we installed NVM in our agents. That way we can select which version of node we want for each project or build, we just need to source the NVM file (to have access to the nvm command at that build step) and use the version that we need (or fallback if it hasn't be installed yet)