找不到模块“较少"时出现webpack错误 [英] webpack error in Cannot find module 'less'

查看:111
本文介绍了找不到模块“较少"时出现webpack错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在webpack中使用较少的加载器,问题是-我在本地安装了较少的加载器,但是当我尝试在bask中使用webpack命令编译所有内容时,它会打印出:无法找到模块'较少的'".在我的入口点,我需要一些更少的文件,例如

I'm trying to use less loader in webpack and the issues is - I've installed less loader locally, but when I try to compile everything using webpack command in bask, it prints out: "ERROR in Cannot find module 'less'". In my entry point I require some less file like

require("./less_components/style.less");

这是我的webpack.config文件

Here is my webpack.config file

module.exports = {

entry: "./entry.js",

output: {

    path: "./build",

    filename: "./bundle.js"

},

module: {

    loaders: [

        {test: /\.js$/, exlude: /node_modules/, loader: "babel-loader"},

        {test: /\.less$/, loader: "style!css!less"}

    ]
}
}

出什么事了,我应该怎么解决?

What's the matter and how I should fix it?

推荐答案

听起来您尚未将less-loader安装到您的node_modules中.安装它可以解决此问题.

It sounds like you haven't installed the less-loader into your node_modules. Installing it would fix this.

npm install less-loader --save-dev

同样,当您未安装要链接到less-loadercss-loaderstyle-loader时,也会收到此错误.

Also you will get this error when you haven't installed the css-loader and style-loader that you are chaining less-loader to.

遇到此问题的任何人都可以加上我为不良消息提交的问题. 缺少更少的加载器,经过多次链接后,找不到模块'less'的错误".修改错误消息.

Anyone who comes across this can plus on the issue I submitted for the bad message. "Error in Cannot find module 'less'" when missing loaders chained after less. Revise error message.

这篇关于找不到模块“较少"时出现webpack错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆