npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm Command not found -- path variable issue?

I’m getting the command not found when I try run a command from npm scripts.

It’s just a simple webpack build command that won’t work if I use

npm run build

Here are my scripts

"scripts": {
    "dev": "webpack --mode development",
    "build": "webpack --mode production"

I think it’s a path configuration, because if I run

./node_modules/.bin/webpack --mode development

the command works fine.

I’m using iTerm 2 with oh-my-zsh on mac

If you have any ideas that would be amazing!
Apologies if I should post this somewhere else! I’m at my wits end trying to figure it out!

Here’s the error I keep getting

sh: webpack: command not found
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! React_tut@1.0.0 dev: `webpack --mode development`
npm ERR! spawn ENOENT