npm run dev Error: Cannot find module build/webpack.dev.conf.js

Posted — Feb 21, 2018

Ran into an issue where I kept getting an ‘Error: Cannot find build/webpack.dev.conf.js’ when trying to run ‘npm run dev’ on a Vue.js webpack project, like the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
nalis-MacBook-Air:dashv2 nali$ npm run dev

> [email protected] dev /Users/nali/Downloads/test/playground/dashv2
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

module.js:557
    throw err;
    ^

Error: Cannot find module '/Users/nali/Downloads/test/playground/dashv2/build/webpack.dev.conf.js'
    at Function.Module.\_resolveFilename (module.js:555:15)
    at Function.Module.\_load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at requireConfig (/Users/nali/Downloads/test/playground/dashv2/node\_modules/webpack/bin/convert-argv.js:97:18)

The problem was that I was checking out a folder that had a lot of different directories, with code written in different languages, and the top level .gitignore included ‘build/’ for Python. Either add ‘!build/’ to a .gitignore in the root folder of the node project when checking it in…or do a better job separating projects and folders like a sensible person.