为什么 require('webpack') 就会出错。
我的 webpack.config.js 是这样的:
js
var webpack = require('webpack'); module.exports = { entry: { zyfaq: "./app/zyfaq/zyfaq.js" }, output: { path: __dirname + '/public/js', filename: "[name].min.js" }, module: { loaders: [ { test: /\.css$/, loader: "style!css" } ] } };
错误提示:
module.js:338
throw err;
^
Error: Cannot find module 'webpack'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/cos800/zhaoyang/webpack.config.js:2:15)
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)
但是我把第一行
var webpack = require('webpack');
去掉就不会出错了。
我又重新安装 webpack 并安装到项目内,又出现以下错误:
% sudo cnpm install webpack
Password:
-
> [email protected] install /Users/cos800/zhaoyang/node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: getaddrinfo ENOTFOUND npm.taobao.org
gyp ERR! stack at errnoException (dns.js:44:10)
gyp ERR! stack at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)
gyp ERR! System Darwin 14.1.0
gyp ERR! command "node" "/usr/local/lib/node_modules/cnpm/node_modules/npm-for-cnpm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/cos800/zhaoyang/node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/fsevents
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]
[email protected] node_modules/webpack
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])
node.js web前端开发 前端 webpack JavaScript
Callll酱
10 years, 1 month ago