Skip to content

Commit 4542e93

Browse files
committed
chore(nodejs): exit installation if Node.js version is unsupported
1 parent 820fdda commit 4542e93

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

recipes/newrelic/apm/node/linux.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,30 @@ preInstall:
2424
if [ -z "$ASSERT_NODE_INSTALLED" ] ; then
2525
exit 1
2626
fi
27+
28+
LOWEST_SUPPORTED_MAJOR_NODE_VERSION=16
29+
NODEJS_BINARY_PATH=$(command -v node)
30+
INSTALLED_MAJOR_NODE_VERSION=$($NODEJS_BINARY_PATH -v | awk -F '[^0-9]+' '{ print $2 }')
31+
if [ "$INSTALLED_MAJOR_NODE_VERSION" -lt "$LOWEST_SUPPORTED_MAJOR_NODE_VERSION" ]; then
32+
echo "Error: Node.js version not supported. Please upgrade to the latest supported version." >&2
33+
exit 132
34+
fi
35+
2736
ASSERT_NPM_INSTALLED=$(sudo -i -u $SUDO_USER command -v npm)
2837
if [ -z "$ASSERT_NPM_INSTALLED" ] ; then
2938
exit 2
3039
fi
40+
3141
# Only PM2 is supported at this time
3242
ASSERT_PM2_INSTALLED=$(sudo -i -u $SUDO_USER command -v pm2)
3343
if [ -z "$ASSERT_PM2_INSTALLED" ] ; then
44+
echo "Error: PM2 is required to complete installation." >&2
3445
exit 132
3546
fi
47+
3648
IS_PM2_RUNNING=$(sudo ps aux | grep pm2 | grep -v grep | wc -l)
3749
if [ $IS_PM2_RUNNING -eq 0 ] ; then
50+
echo "Error: PM2 not running. Please start PM2 and retry the installation." >&2
3851
exit 132
3952
fi
4053
exit 0

0 commit comments

Comments
 (0)