Error with webpack when follow the official guide
When I learn webpack I follow this tutorial: http://webpack.github.io/docs/tutorials/getting-started/
I run webpack ./entry.js bundle.js
after I have installed webpack (use the same command as the tutorial) and create only exact files as tutorail. Then I got the error.
"module.js:338
throw err;
^
Error: Cannot find module 'assert/'
at Function.Module._resolveFilename (module.js:336:15)
at Function.require.resolve (module.js:388:19)
at Object.<anonymous> (/usr/local/lib/node_modules/node-libs-browser/index.js:1:93)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/webpack/lib/node/NodeSourcePlugin.js:7:23)
"
The osx environment is 10.10.3 and node is v0.12.4. How can I fix this?
source to share
Are you sure Webpack is installed correctly on your system?
Whichever is preferred, use a local installation. Here are some quick instructions to get you away. Follow in your project directory:
-
npm init
- Just hit the comeback for everything until you feel like setting up some. This will create
package.json
in the root of the project - Click
npm i webpack --save-dev
. This will add Webpack as a dependency of your project development. - Hit
node_modules/.bin/webpack ./entry.js bundle.js
Alternatively, you can set up a section scripts
like this on your package.json
:
{
"scripts": {
"build": "webpack ./entry.js bundle.js"
}
}
If pressed after that npm run build
, it will do the same.
I'll go into detail on my free book on webpack . You can find more advanced ways to deal with it.
source to share