diff --git a/plugins/nodejs.json b/plugins/nodejs.json index 2d2ebc0b1e2..6497ddabd07 100644 --- a/plugins/nodejs.json +++ b/plugins/nodejs.json @@ -1,12 +1,18 @@ { "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/main/.schema/devbox-plugin.schema.json", - "version": "0.0.2", + "version": "0.0.3", "name": "nodejs", "readme": "Devbox automatically configures Corepack for Nodejs when DEVBOX_COREPACK_ENABLED=1. You can install Yarn or Pnpm by adding them to your `package.json` file using `packageManager`\nCorepack binaries will be installed in your local `.devbox` directory", "shell": { "init_hook": [ - "test -z $DEVBOX_COREPACK_ENABLED || corepack enable --install-directory \"{{ .Virtenv }}/corepack-bin/\"", - "test -z $DEVBOX_COREPACK_ENABLED || export PATH=\"{{ .Virtenv }}/corepack-bin/:$PATH\"" + "if [ -n \"$DEVBOX_COREPACK_ENABLED\" ]; then", + " if command -v corepack >/dev/null 2>&1; then", + " corepack enable --install-directory \"{{ .Virtenv }}/corepack-bin/\"", + " export PATH=\"{{ .Virtenv }}/corepack-bin/:$PATH\"", + " else", + " echo 'Warning: DEVBOX_COREPACK_ENABLED is set but corepack was not found. The nodejs-slim package no longer ships corepack; use the nodejs package instead, or add corepack to your packages.' >&2", + " fi", + "fi" ] }, "create_files": {