• vue项目用npm安装sass包遇到的问题及解决办法


    IDEA启动vue程序,浏览器访问时出现如下情况的关于node-sass的错误:

    错误1:

    Module build failed (from ./node_modules/sass-loader/dist/cjs.js)

    Error:Cannot find module 'node-sass'

    错误2:

    Module build failed (from ./node_modules/sass-loader/dist/cjs.js)

    Error:no such file or directory, open 'D:SourceProjectsichebangongcar-pub-vue ode_modules ode-sasslibindex.js'

    Failed to compile.
    
    ./src/back/views/user/Login.vue?vue&type=style&index=0&id=1503f165&lang=scss&scoped=true& (./node_modules/css-loader??ref--8-oneOf-1-1!./node_modules/@vue/cli-service/node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/back/views/user/Login.vue?vue&type=style&index=0&id=1503f165&lang=scss&scoped=true&)
    Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
    Error: ENOENT: no such file or directory, open 'D:SourceProjectsichebangongcar-pub-vue
    ode_modules
    ode-sasslibindex.js'
        at Object.openSync (fs.js:440:3)
        at Object.readFileSync (fs.js:342:35)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:994:22)
        at Module.load (internal/modules/cjs/loader.js:815:32)
        at Function.Module._load (internal/modules/cjs/loader.js:727:14)
        at Module.require (internal/modules/cjs/loader.js:852:19)
        at require (internal/modules/cjs/helpers.js:74:18)
        at getDefaultSassImpl (D:SourceProjectsichebangongcar-pub-vue
    ode_modulessass-loaderdistindex.js:198:10)
        at Object.loader (D:SourceProjectsichebangongcar-pub-vue
    ode_modulessass-loaderdistindex.js:80:29)

    查看项目的node_modules目录,有sass-loader,却没有node-sass。

    安装sass吧。命令:

    npm install node-sass -g

    可是,在执行命令时提示了好多错误,如

    Cannot download "https://github.com/sass/node-sass/releases/download/v4.13.0/win32-x64-72_binding.node", 原因是sockettimedout。

    MSBUILD : error MSB4132: 无法识别工具版本“2.0”。可用的工具版本为 "4.0"

    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

    python

    网上资料有很多,不过每个人的情况不一样,所以,并没有解决我的问题。

    最终解决办法是使用cnpm命令取代npm,成功安装sass包。

    cnpm uninstall node-sass
    cnpm install node-sass
  • 相关阅读:
    oracle的优化-----学习笔记
    面试题-------笔记
    HTTP-1.初相识:了解HTTP协议
    Python-Basis-6th
    Python-Basis-5th
    Python-Basis-4th
    Python-Basis-3rd
    Python-Basis-2nd
    Python-Basis-1st
    scala面向对象编程
  • 原文地址:https://www.cnblogs.com/buguge/p/12098357.html
Copyright © 2020-2023  润新知