vue project installation problems encountered with sass package npm and solutions

 

IDEA start vue program, follows what happens when a browser to access an error on the node-sass:

Error 1:

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

Error:Cannot find module 'node-sass'

Error 2:

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

Error:no such file or directory, open 'D:\SourceProject\sichebangong\car-pub-vue\node_modules\node-sass\lib\index.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:\SourceProject\sichebangong\car-pub-vue\node_modules\node-sass\lib\index.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:\SourceProject\sichebangong\car-pub-vue\node_modules\sass-loader\dist\index.js:198:10)
    at Object.loader (D:\SourceProject\sichebangong\car-pub-vue\node_modules\sass-loader\dist\index.js:80:29)

 

node_modules catalog items, there sass-loader, but not node-sass.

Sass install it. Command: npm install node-sass -g

It prompted a lot of errors, such as

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

MSBUILD: error MSB4132: Tools does not recognize the version "2.0." Available version of the tool is "4.0"

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

python

 

There are a lot of online information, but each person's situation is different, therefore, does not solve my problem.

The final solution is to use the command cnpm

cnpm uninstall node-sass
cnpm install node-sass

Sass successful installation package.

 

Guess you like

Origin www.cnblogs.com/buguge/p/12098357.html