Home >Web Front-end >JS Tutorial >Introduction to the problem solving method of installing node-sass with npm and yarn

Introduction to the problem solving method of installing node-sass with npm and yarn

不言
不言forward
2019-03-23 16:19:404168browse

This article brings you an introduction to the problem solving method of installing node-sass in npm and yarn. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

node-sass

When npm installs the node-sass dependency, it will download the .node file from github.com. Due to problems with the domestic network environment, this download may take a long time, or even cause a timeout failure.
This is a frustrating problem that students who use sass may encounter.

npm download

The solution is as follows

1Switch Taobao source directly

局部设置
npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
全局设置
npm config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/

2Add configuration file.npmrc

sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
registry=https://registry.npm.taobao.org

The above method You can download it successfully

yarn download

Yarn download is much more difficult than npm
The appeal switch will still fail
You need to download the package manually

When we yarn downloads node-sass, an error will be reported. This is mainly due to an error during parsing.
Let’s check the files under the node_modulesnode-sassvendor path
I assume it is win32-x64-57
But the inside of the folder is empty
The files inside are downloaded, and when they finally arrive Parsing failed. We need to download this file manually
https://github.com/sass/node-...
Find the win32-x64-57 version of binding.node at the above address; that is, win32-x64-57_binding .node
Download.
Then we need to find the cache address of yarn. When downloading yarn, we always check the cache first.
We can find the corresponding cache address through

yarn cash dir


My side It is

C:\Users\xxx\AppData\Local\Yarn\Cache\v1

Then find the corresponding node-sass
We can see that there is no vendor file inside, so copy the vendor folder just now and add win32-x64-57_binding.node Rename binding.node and put it under the win32-x64-57 folder. If you download it again, you can download it successfully.

This article is over here. For more exciting content, you can pay attention to the PHP Chinese website. The JavaScript video tutorial column!

The above is the detailed content of Introduction to the problem solving method of installing node-sass with npm and yarn. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete