如果您想訂閱本博客內(nèi)容,每天自動(dòng)發(fā)到您的郵箱中, 請(qǐng)點(diǎn)這里
    
    
        關(guān)于 node 環(huán)境升級(jí)到 v8^ 以上,node-sass 報(bào)錯(cuò)的解決方法
    
    
        今天給同事電腦升級(jí)了一下系統(tǒng),順便升級(jí)了所有的軟件,發(fā)現(xiàn)原來(lái)好好的項(xiàng)目報(bào)錯(cuò)了。報(bào)錯(cuò)大致信息如下:
    
 ERROR Failed to compile with 1 errors                                                                      下午1:56:26 error in ./src/components/Hello.vue Module build failed: Error: Missing binding /Users/fungleo/Sites/MyWork/vuedemo2/node_modules/node-sass/vendor/darwin-x64-57/binding.node Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 8.x Found bindings for the following environments: - OS X 64-bit with Node.js 6.x This usually happens because your environment has changed since running `npm install`. Run `npm rebuild node-sass --force` to build the binding for your current environment.
    at module.exports (/Users/fungleo/Sites/MyWork/vuedemo2/node_modules/node-sass/lib/binding.js:15:13) at Object.<anonymous> (/Users/fungleo/Sites/MyWork/vuedemo2/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at Object.<anonymous> (/Users/fungleo/Sites/MyWork/vuedemo2/node_modules/sass-loader/lib/loader.js:3:14)
    at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) at Module.require (module.js:579:17) @ ./~/vue-style-loader!./~/css-loader?{"minimize":false,"sourceMap":false}!./~/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-2d1bdf0c","scoped":false,"hasInlineConfig":false}!./~/sass-loader/lib/loader.js?{"sourceMap":false}!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/components/Hello.vue 4:14-394 13:3-17:5 14:22-402 @ ./src/components/Hello.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi ./build/dev-client ./src/main.js
> Listening at http://localhost:8080
    
        - 
            1
        
- 
            2
        
- 
            3
        
- 
            4
        
- 
            5
        
- 
            6
        
- 
            7
        
- 
            8
        
- 
            9
        
- 
            10
        
- 
            11
        
- 
            12
        
- 
            13
        
- 
            14
        
- 
            15
        
- 
            16
        
- 
            17
        
- 
            18
        
- 
            19
        
- 
            20
        
- 
            21
        
- 
            22
        
- 
            23
        
- 
            24
        
- 
            25
        
- 
            26
        
- 
            27
        
- 
            28
        
- 
            29
        
- 
            30
        
- 
            31
        
- 
            32
        
- 
            33
        
- 
            34
        
- 
            35
        
- 
            36
        
        這段代碼是我升級(jí)node之后,在我的電腦上復(fù)制出來(lái)的。但大概就是這么個(gè)意思,里面根據(jù)不同的項(xiàng)目位置什么的,會(huì)有所不同。
    
    
        簡(jiǎn)單的說(shuō),這段代碼就是告訴你,node-sass 不兼容 node v8 的版本。那就很好解決了。在當(dāng)前項(xiàng)目下面執(zhí)行
    
npm i node-sass -D
    
    
        然后項(xiàng)目就恢復(fù)正常了。
    
    
        當(dāng)項(xiàng)目出錯(cuò)之后,不要著急,仔細(xì)看下報(bào)錯(cuò)代碼,實(shí)在不行用翻譯工具翻譯一下。一般來(lái)說(shuō),是很快能夠找到解決方法的。
    
藍(lán)藍(lán)設(shè)計(jì)( m.monmeltingpot.net )是一家專注而深入的界面設(shè)計(jì)公司,為期望卓越的國(guó)內(nèi)外企業(yè)提供卓越的UI界面設(shè)計(jì)、BS界面設(shè)計(jì) 、 cs界面設(shè)計(jì) 、 ipad界面設(shè)計(jì) 、 包裝設(shè)計(jì) 、 圖標(biāo)定制 、 用戶體驗(yàn) 、交互設(shè)計(jì)、 網(wǎng)站建設(shè) 、平面設(shè)計(jì)服務(wù)。