惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
博客园_首页
H
Help Net Security
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
B
Blog
I
InfoQ
SecWiki News
SecWiki News
T
Tailwind CSS Blog
Spread Privacy
Spread Privacy
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
P
Palo Alto Networks Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
M
MIT News - Artificial intelligence
S
Schneier on Security
T
Threat Research - Cisco Blogs
F
Fortinet All Blogs
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The Cloudflare Blog
Recent Announcements
Recent Announcements
Security Latest
Security Latest
G
GRAHAM CLULEY
IT之家
IT之家
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
腾讯CDC
Google DeepMind News
Google DeepMind News
V
V2EX
S
Securelist
TaoSecurity Blog
TaoSecurity Blog
B
Blog RSS Feed
S
SegmentFault 最新的问题
博客园 - 叶小钗
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Project Zero
Project Zero
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure

博客园 - 张旋

如何管理自己? 解决play-1.4.0在linux或mac下提示No such file or directory的问题 PlayFramework 1.2.x 在Controller 中识别JSON提交 写了一个小游戏 Java 动态编译 Play! Framework —— 颠覆“企业级”=“复杂”的观念 JDK 7出人意料将增加“简单”闭包,发布时间推迟至明年底 冷观PDM PDM在中国为什么比ERP更难成功实施? 什么是PDM Hibernate查询快速入门 策略→需求→建模→规划→执行 什么是BNF范式,什么又是EBNF范式? - 张旋 - 博客园 又是好久不写日志 发现自己的blog里有很多好东西 近期杂感 现在的我,有两个状态。我要去找第三个 开发通用类时遇到的几个问题 我是5型
node-sass 安装卡在 node scripts/install.js 解决办法
张旋 · 2016-12-13 · via 博客园 - 张旋

转自:https://segmentfault.com/a/1190000005921721

======== 7月12日更新 ========

总的来说就是两种方法解决:

SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm install

或者在 ~/.npmrc 里添加下面这行(参考),保存后再 npm install
(如果是用的 cnpm,需要添加到 ~/.cnpmrc)

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

以下的内容主要是这个问题出现的分析,有兴趣就看

======== 7月10日更新 ========

评论提醒了我,npm.taobao.org 已经收录了 node-sass 的源码,可以直接指定下载的地址,参考:

https://github.com/lmk123/blog/issues/28

https://cnodejs.org/topic/5637549fd426a1404cbd0614

============ 原文 ============

一个 node 项目里用到了 node-sass@3.8.0 ,安装的时候在这一步:

> node-sass@3.8.0 install path/to/project/node_modules/node-sass
> node scripts/install.js

一直卡住,至少有半个小时没反应,自己的 Mac 和腾讯云的服务器上都是这样

去看 node_modules/node-sass/scripts/install.js 的代码,发现是要在 GitHub 上下载编译好的 node-sass 二进制包 ,去看 node-sass 的 Release,平均在 2.5 MB 左右

于是明了了,GitHub 在国内访问本来就不稳定,然后还是用 request 去访问,就更慢了。看了一下,半个小时左右才下了 500 K

正好又在 这里 的 getBinaryPath() 可以设置二进制的位置。在这之前还要先知道自己的系统需要的版本。

用这行命令:

node -p "[process.platform, process.arch, process.versions.modules].join('-')"

复制输出的结果,去 Release 列表 找到对应的版本,Ctrl+F 粘贴,找到那个文件,下载(必要的时候挂代理,浏览器下载通常都比 node 下载更快更稳定),然后文件存到一个稳定的路径,并复制路径(比如 ~/.node/.npm/node-sass/darwin-x64-48_binding.node

在 ~/.npmrc 下面新增一行,新增 sass_binary_path 项并填入刚才的路径,比如

sass_binary_path=/home/ubuntu/.npm/node-sass/darwin-x64-48_binding.node

最后再去项目目录下:

rm -rf node_modules/ && npm i