webpack Cannot resolve module 'css'?

var path = require('path');
var webpack = require('webpack');

module.exports = {
    entry: ['./src/index.js'],
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'bundle.js'
    },
    plugins: [
        new webpack.optimize.UglifyJsPlugin({
            compressor: {
                warnings: false
            }
        })
    ],
    module: {
        loaders: [{
            test: /\.css$/,
            loaders: ['style', 'css']
        }]
    }
}


package.json
   {
  "name": "demo1",
  "version": "1.0.0",
  "description": "demo",
  "main": "webpack.config.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "demo",
  "license": "ISC",
  "keywords": [
    "demo"
  ],
  "dependencies": {
    "style-loader": "^0.13.1"
  },
  "devDependencies": {}
}

图片描述

阅读 3.4k
3 个回答

贴出详细错误吧,从你现在的描述看,只能推测出你没有本地安装css-loader

css-loader装么有……

package.json 贴出来

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题