Saturday 19 January 2019

node.js - Error: Cannot find module 'webpack'

I'm just getting started with webpack and am having difficulty getting the multiple-entry-points sample to build. The webpack.config.js file in the example includes the line



 var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");



which fails for me with the error



Error: Cannot find module '../../lib/optimize/CommonsChunkPlugin'


Searching around, I found other examples of using the CommonsChunkPlugin with the expression



var commonsPlugin = new webpack.optimize.CommonsChunkPlugin("common.js");



which fails with the error



ReferenceError: webpack is not defined


Some more searching found a number of examples including



var webpack = require('webpack');



and my build now fails with



Error: Cannot find module 'webpack'


I'm at a loss as to how to proceed.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...