The mcp23017 node installs the i2c node, but the incorrect version. See this topic.
Try installing i2c first:
cd /home/pi/.node-red
npm install https://github.com/nielsnl68/node-red-contrib-i2c.git
Hold on from here:
You want to install node-red-contrib-mcp23017
But you typed: npm install node-mcp23017
2 different things.
1 is a node-red-node,
1 is the nodejs package - which is the one you tried to install.
However, node-red-contrib-mcp23017
has not been updated for 4 years. Perhaps you need to try a more recent version as there are more nodes that support the mcp23017.
May I suggest you use the editor first, it is easier: hamburger menu -> manage palette -> install tab -> search for mcp23017 -> install.