Since the nix store is immutable and cannot be modified, you need to define a writable location for NPM packages to be installed globally.
Install NodeJS if you haven’t already.
Add the following to your ~/.npmrc
to have it put the packages in the ~/.npm-packages
folder:
prefix = ${HOME}/.npm-packages
You need to add the npm bin folder to your PATH in your shell’s rc file (i.e. .bashrc or .zshrc for example, so you can access the executables: