Open Tate-CC opened 2 years ago
It looks like the offending function is here: https://github.com/gohugoio/hugo/blob/41cc4e4ba3bd849cee7dcb691504ebebbfce680f/common/hugo/hugo.go#L108-L131 And the logic should instead be something like:
nodepath := filepath.Join(workDir, "node_modules")
if np := os.Getenv("NODE_PATH"); np != "" {
nodepath = nodepath + string(os.PathListSeparator) + np
}
I'd be happy to go ahead and put this in a PR if that makes things easier 🙂
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
This issue does reproduce with the latest version.
When the NODE_PATH environment variable is unset, the Hugo exec environment correctly has NODE_PATH set as the node_modules directory of the current working directory. When the NODE_PATH is already set, however, the NODE_PATH is instead prepended with the current working directory but not the node_modules folder. This means that if you have a module which relies on locally installed modules, for example a PostCSS plugin, it can't find them and the build fails.