0

Take the path

/a/b/c/package.json
/a/b/c/package-lock.json

From /, this works without error:

cd /a/b/c && npm install

However, from /, this throws an error:

cd /a/b/c && npm run build

With the error being:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

What's extra odd is that npm run build then proceeds to complete successfully. The error is only thrown while npm is looking up the build script. However, this is enough to trick my CI/CD pipeline into thinking the whole command has failed.

How can I execute npm run *** from another directory without this initial error?

Tyler V.
  • 2,471
  • 21
  • 44

0 Answers0