nodemon-webpack-plugin: Crash on [hash] or [name] in webpack output filename

When you have a webpack config like: (example)

module.exports = {
  entry: './src/index.js',
  output: {
    filename: '[name]-[hash].js',
    path: 'dist'
  }
}

Webpack will fail starting with this error:

npm info it worked if it ends with ok
npm info using npm@5.3.0
npm info using node@v8.4.0
npm info lifecycle app-core@1.0.0~prewatch: app-core@1.0.0
npm info lifecycle app-core@1.0.0~watch: app-core@1.0.0

> app-core@1.0.0 watch /usr/app
> NODE_ENV=development webpack --watch


Webpack is watching the files…

ts-loader: Using typescript@2.5.2 and /usr/app/tsconfig.json
/usr/app/node_modules/nodemon-webpack-plugin/dist/index.js:14
    var absoluteFileName = asset.existsAt;
                                ^

TypeError: Cannot read property 'existsAt' of undefined
    at getOutputFileMeta (/usr/app/node_modules/nodemon-webpack-plugin/dist/index.js:14:33)
    at Compiler.<anonymous> (/usr/app/node_modules/nodemon-webpack-plugin/dist/index.js:43:46)
    at Compiler.applyPluginsAsyncSeries1 (/usr/app/node_modules/tapable/lib/Tapable.js:222:13)
    at Compiler.afterEmit (/usr/app/node_modules/webpack/lib/Compiler.js:365:9)
    at require.forEach.err (/usr/app/node_modules/webpack/lib/Compiler.js:354:15)
    at /usr/app/node_modules/async/dist/async.js:421:16
    at iteratorCallback (/usr/app/node_modules/async/dist/async.js:998:13)
    at /usr/app/node_modules/async/dist/async.js:906:16
    at /usr/app/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)
npm info lifecycle app-core@1.0.0~watch: Failed to exec watch script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app-core@1.0.0 watch: `NODE_ENV=development webpack --watch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the app-core@1.0.0 watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

getOutputFileMeta will give an error, because the name [name].js is not in the assets (only the compiled name: index.js).

It would be nice if the plugin could convert these filenames.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 25 (11 by maintainers)

Most upvoted comments

I got a similar error:

/node_modules/nodemon-webpack-plugin/dist/webpack-utils.js:13
  var absoluteFileName = asset.existsAt;
                               ^

TypeError: Cannot read property 'existsAt' of undefined
    at getOutputFileMeta (/mnt/c/Users/username/repository/tic-tac-toe/src/game-server/node_modules/nodemon-webpack-plugin/dist/webpack-utils.js:13:32)
    at OnAfterEmit (/mnt/c/Users/username/repository/tic-tac-toe/src/game-server/node_modules/nodemon-webpack-plugin/dist/index.js:35:36)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/mnt/c/Users/username/repository/tic-tac-toe/src/game-server/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook (/mnt/c/Users/username/repository/tic-tac-toe/src/game-server/node_modules/tapable/lib/Hook.js:154:20)
    at asyncLib.forEachLimit.err (/mnt/c/Users/username/repository/tic-tac-toe/src/game-server/node_modules/webpack/lib/Compiler.js:432:27)
    at Object.eachLimit (/mnt/c/Users/username/repository/tic-tac-toe/src/game-server/node_modules/neo-async/async.js:3461:14)
    at emitFiles (/mnt/c/Users/username/repository/tic-tac-toe/src/game-server/node_modules/webpack/lib/Compiler.js:321:13)
    at Immediate.<anonymous> (/mnt/c/Users/username/repository/tic-tac-toe/src/game-server/node_modules/memory-fs/lib/MemoryFileSystem.js:288:4)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)

I’ll have a look tonight (GMT).