解决vue安装less报错Failed to compile with 1 errors的问题

(编辑:jimmy 日期: 2024/12/23 浏览:2)

1、创建vue项目后安装less,执行 npm install less less-loader --save-dev

下载版本为:less-loader@6.1.0 , less@3.11.3,重启服务报错,报错信息如下:

解决vue安装less报错Failed to compile with 1 errors的问题

2、报错原因 less 本版太高需要降低版本,执行代码

先移除之前版本:

npm uninstall less-loader

下载指定版本:

npm install less-loader@5.0.0 -D

3、重启代码就可以了,若还是报错可移除文件node_modules,重新下载cnpm install

补充知识:vue项目运行报错:94% asset optimization ERROR Failed to compile with 2 errors13:03:01 error in ./src/ba

使用vue编写的前端项目运行报错:

88% hashing
89% module assets processing
90% chunk assets processing
94% asset optimization ERROR Failed to compile with 2 errors13:03:01
error in ./src/base/components/head.vue
Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (72)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.7.2
at module.exports (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\node-sass\lib\binding.js:13:13)
at Object.<anonymous> (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\sass-loader\lib\loader.js:3:14)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at loadLoader (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\loader-runner\lib\loadLoader.js:13:17)

@ ./node_modules/vue-style-loader!./node_modules/css-loader"sourceMap":false}!./node_modules/vue-loader/lib/style-compiler"vue":true,"id":"data-v-1340bee1","scoped":true,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js"sourceMap":false}!./node_modules/vue-loader/lib/selector.js"" src="/UploadFiles/2021-04-02/20201022095413.jpg">

3、重新安装更新版本的node-sass即可

npm install --save node-sass (cnpm install --save node-sass )

(这个也要在指定文件夹执行,并进行本地安装)

这样就可以了!!!!!!!!!

如下图所示:

解决vue安装less报错Failed to compile with 1 errors的问题

以上这篇解决vue安装less报错Failed to compile with 1 errors的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。