Skip to content

Instantly share code, notes, and snippets.

@MJ111
Last active August 9, 2017 12:28
Show Gist options
  • Save MJ111/bc7175ceab84e92df263df5adc1c6b9f to your computer and use it in GitHub Desktop.
Save MJ111/bc7175ceab84e92df263df5adc1c6b9f to your computer and use it in GitHub Desktop.
can't resolve 'tls' 'fs', ... when running webpack-dev-server issue

Don't pass file name as argument

$ node_modules/webpack-dev-server/bin/webpack-dev-server.js webpack.config.js

This will raises errors like this.

    ERROR in ./~/tunnel-agent/index.js
    Module not found: Error: Can't resolve 'net' in '/Users/projects/frontend/node_modules/tunnel-agent'
     @ ./~/tunnel-agent/index.js 3:10-24
     @ ./~/request/lib/tunnel.js
     @ ./~/request/request.js
     @ ./~/request/index.js
     @ ./~/node-gyp/lib/install.js
     @ ./~/node-gyp/lib ^\.\/.*$
     @ ./~/node-gyp/lib/node-gyp.js
     @ ./~/fsevents/~/node-pre-gyp/lib/util/compile.js
     @ ./~/fsevents/~/node-pre-gyp/lib ^\.\/.*$
     @ ./~/fsevents/~/node-pre-gyp/lib/node-pre-gyp.js
     @ ./~/fsevents/fsevents.js
     @ ./~/chokidar/lib/fsevents-handler.js
     @ ./~/chokidar/index.js
     @ ./~/watchpack/lib/DirectoryWatcher.js
     @ ./~/watchpack/lib/watcherManager.js
     @ ./~/watchpack/lib/watchpack.js
     @ (webpack)/lib/node/NodeWatchFileSystem.js
     @ (webpack)/lib ^.*$
     @ (webpack)/lib/webpack.js
     @ ./webpack.config.js
     @ multi (webpack)-dev-server/client?http://localhost:3000 ./webpack.config.js

    ERROR in ./~/tunnel-agent/index.js
    Module not found: Error: Can't resolve 'tls' in '/Users/projects/frontend/node_modules/tunnel-agent'
     @ ./~/tunnel-agent/index.js 4:10-24
     @ ./~/request/lib/tunnel.js
     @ ./~/request/request.js
     @ ./~/request/index.js
     @ ./~/node-gyp/lib/install.js
     @ ./~/node-gyp/lib ^\.\/.*$
     @ ./~/node-gyp/lib/node-gyp.js
     @ ./~/fsevents/~/node-pre-gyp/lib/util/compile.js
     @ ./~/fsevents/~/node-pre-gyp/lib ^\.\/.*$
     @ ./~/fsevents/~/node-pre-gyp/lib/node-pre-gyp.js
     @ ./~/fsevents/fsevents.js
     @ ./~/chokidar/lib/fsevents-handler.js
     @ ./~/chokidar/index.js
     @ ./~/watchpack/lib/DirectoryWatcher.js
     @ ./~/watchpack/lib/watcherManager.js
     @ ./~/watchpack/lib/watchpack.js
     @ (webpack)/lib/node/NodeWatchFileSystem.js
     @ (webpack)/lib ^.*$
     @ (webpack)/lib/webpack.js
     @ ./webpack.config.js
     @ multi (webpack)-dev-server/client?http://localhost:3000 ./webpack.config.js

    ERROR in ./~/isexe/windows.js
    Module not found: Error: Can't resolve 'fs' in '/Users/projects/frontend/node_modules/isexe'
     @ ./~/isexe/windows.js 4:9-22
     @ ./~/isexe/index.js
     @ ./~/which/which.js
     @ ./~/node-gyp/lib/build.js
     @ ./~/node-gyp/lib ^\.\/.*$
     @ ./~/node-gyp/lib/node-gyp.js
     @ ./~/fsevents/~/node-pre-gyp/lib/util/compile.js
     @ ./~/fsevents/~/node-pre-gyp/lib ^\.\/.*$
     @ ./~/fsevents/~/node-pre-gyp/lib/node-pre-gyp.js
     @ ./~/fsevents/fsevents.js
     @ ./~/chokidar/lib/fsevents-handler.js
     @ ./~/chokidar/index.js
     @ ./~/watchpack/lib/DirectoryWatcher.js
     @ ./~/watchpack/lib/watcherManager.js
     @ ./~/watchpack/lib/watchpack.js
     @ (webpack)/lib/node/NodeWatchFileSystem.js
     @ (webpack)/lib ^.*$
     @ (webpack)/lib/webpack.js
     @ ./webpack.config.js
     @ multi (webpack)-dev-server/client?http://localhost:3000 ./webpack.config.js

    ERROR in ./~/isexe/mode.js
    Module not found: Error: Can't resolve 'fs' in '/Users/minjeongkim/mmt/projects/mmt_msa-frontend/node_modules/isexe'
     @ ./~/isexe/mode.js 4:9-22
     @ ./~/isexe/index.js
     @ ./~/which/which.js
     @ ./~/node-gyp/lib/build.js
     @ ./~/node-gyp/lib ^\.\/.*$
     @ ./~/node-gyp/lib/node-gyp.js
     @ ./~/fsevents/~/node-pre-gyp/lib/util/compile.js
     @ ./~/fsevents/~/node-pre-gyp/lib ^\.\/.*$
     @ ./~/fsevents/~/node-pre-gyp/lib/node-pre-gyp.js
     @ ./~/fsevents/fsevents.js
     @ ./~/chokidar/lib/fsevents-handler.js
     @ ./~/chokidar/index.js
     @ ./~/watchpack/lib/DirectoryWatcher.js
     @ ./~/watchpack/lib/watcherManager.js
     @ ./~/watchpack/lib/watchpack.js
     @ (webpack)/lib/node/NodeWatchFileSystem.js
     @ (webpack)/lib ^.*$
     @ (webpack)/lib/webpack.js
     @ ./webpack.config.js
     @ multi (webpack)-dev-server/client?http://localhost:3000 ./webpack.config.js

Run webpack-dev-server only

$ node_modules/webpack-dev-server/bin/webpack-dev-server.js

There's no config option for webpack config file name in current documentation.

I think only possible option is rename file to webpack.config.js

Tested version

  • webpack: 2.7.0
  • webpack-dev-server: 2.7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment