diff --git a/misc/tools.func b/misc/tools.func index 1edb9505a..8529e2c17 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -74,6 +74,15 @@ function setup_nodejs() { fi export NODE_OPTIONS="--max-old-space-size=4096" + +# Ensure valid working directory for npm (avoids uv_cwd error) + if [[ ! -d /opt ]]; then + mkdir -p /opt + fi + cd /opt || {Add commentMore actions + msg_error "Failed to set safe working directory before npm install" + exit 1 + } # Install global Node modules if [[ -n "$NODE_MODULE" ]]; then