天天看點

vue-項目中less報錯 Module build failed: TypeError: loaderContext.getResolve is not a function問題解決以及安裝less1.檢視你的package.json檔案

vue-項目中less報錯 Module build failed: TypeError: loaderContext.getResolve is not a function問題解決以及安裝less

    • 報錯
    • 參考文檔:
  • 1.檢視你的package.json檔案
    • 1.1安裝less
    • 1.2 打開build目錄
    • 1.3 下載下傳依賴
    • 1.4 然後啟動項目
    • 2 (loaderContext.getResolve is not a function問題解決)
    • 2.1 降低版本(解決問題)
    • 2.2 修改完成以後,重新執行指令
    • 3 問題解決

報錯

UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a pr
omise which was not handled with .catch(). (rejection id: 1)
(node:6572) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non
-zero exit code.

           

參考文檔:

參考文檔

1.檢視你的package.json檔案

看你是否安裝了less

"less": "^3.12.2",
"less-loader": "^4.1.0",
           

1.1安裝less

用cnpm或者npm都可以

npm install less less-loader --save
           

1.2 打開build目錄

在【build】檔案下的【webpack.base.conf.js】檔案中【rules】中加入

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

(根據自己需求)在你自己頁面【style】标簽裡面寫上【lang=“less”】

<style lang="less">
  industry-pro{width: 100%; height: 600px;}
</style>
           

1.3 下載下傳依賴

cnpm i
           

1.4 然後啟動項目

cnpm run dev
           

2 (loaderContext.getResolve is not a function問題解決)

2.1 降低版本(解決問題)

vue-項目中less報錯 Module build failed: TypeError: loaderContext.getResolve is not a function問題解決以及安裝less1.檢視你的package.json檔案

然後修改版本

cnpm run dev
           
vue-項目中less報錯 Module build failed: TypeError: loaderContext.getResolve is not a function問題解決以及安裝less1.檢視你的package.json檔案

2.2 修改完成以後,重新執行指令

cnpm i
           

然後啟動項目

3 問題解決

希望能夠幫到您