I have a few npm packages installed globally npm install <package> -g
.
Before switching environments (dev machine -> server) I could just do import {method} from 'package'
and node would import from global.
I've tried settings node path export NODE_PATH=$(npm root --quiet -g)
as per this answer, but it doesn't work.
How can I tell node to import from the global folder instead trying to import a lcoal package? I'm getting Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ws'
so I assume that is what's happening.
The NODE_PATH
is pointing at the right folder where the packages are installed, but the error shows that it tries to import from a different path.