Encountering a File Not Found Issue with npm on Node.js

Custom-installed Node.js and npm from alternative directories trigger an ENOENT error. For example:

$ mkdir -p ~/custom_install
$ echo 'export PATH=~/custom_install/bin:$PATH' >> ~/.profile
$ cd ~/src/node_app
$ ./setup_install --target=~/custom_install
$ make build

How can this configuration problem be resolved?

hey, try updating your path in .bashrc instead of .profile. sometimes the custom install isn’t picked up due to wrong enviroment vars. also, use abslute paths to ensure npm finds its binaries.

In my experience, this error typically arises when the environment variables do not propagate correctly, especially between login and non-login shells. I encountered a similar problem when I manually installed Node.js and npm into a custom directory. To resolve it, I ensured that the customized path was exported uniformly across all shell sessions and confirmed that the installation directory was referenced with absolute paths in the configuration files. This consistency prevented the system from missing the necessary binaries during execution.

I encountered a similar obstacle while setting up a custom Node.js environment on a different project. What eventually worked for me was explicitly setting the environment variables in a script that was sourced in every terminal session, including interactive shells. I found that discrepancies sometimes arose because the file where the variables were defined wasn’t being universally read. Although I kept experimenting with different shell configurations, eventually I resolved it by updating the shell’s global settings to include a link to the proper directory, ensuring that npm could locate its executables every time.