如何在Sublime Text 3上使用Package Control安装Babel?

时间:2015-09-22 17:04:13

标签: macos sublimetext3 babeljs

我想安装Babel。我使用的是Mac,我已经安装了Sublime Text 3和Package Controll。所以我尝试 cmd + shift + p 打开打包控件,然后输入" 安装"但没有任何表现。我关注this link。我需要使用Babel进行React语法高亮显示。

4 个答案:

答案 0 :(得分:0)

您可以查看Sublime 3放置位置的文件路径。你安装了sudo吗?也许这个链接会有所帮助。

  

http://www.sublimetext.com/forum/viewtopic.php?f=3&t=12909

答案 1 :(得分:0)

有同样的问题,在我的情况下我必须首先安装包控件,我使用"简单安装"将代码从Package.io粘贴到控制台(View> Show Console)中的方法。

对于Sublime 3:

  

import urllib.request,os,hashlib; h =   ' 2915d1851351e5ee549c20394736b442' +   ' 8bc59f460fa1548d1514676163dafc88&#39 ;; pf ='包裹   Control.sublime封装&#39 ;; ipp = sublime.installed_pa​​ckages_path();   urllib.request.install_opener(urllib.request.build_opener(   urllib.request.ProxyHandler())); by = urllib.request.urlopen(   ' http://packagecontrol.io/' + pf.replace('','%20'))。read(); dh =   hashlib.sha256(通过).hexdigest();打印('错误验证下载(得到   %s而不是%s),请尝试手动安装' %(dh,h))如果dh!= h   打开(os.path.join(ip​​p,pf),' wb')。写(by)

和Sublime 2:

  

import urllib2,os,hashlib; h =' 2915d1851351e5ee549c20394736b442' +   ' 8bc59f460fa1548d1514676163dafc88&#39 ;; pf ='包裹   Control.sublime封装&#39 ;; ipp = sublime.installed_pa​​ckages_path();   os.makedirs(ipp)如果不是os.path.exists(ipp)否则无;   urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())   ); by = urllib2.urlopen(' http://packagecontrol.io/' + pf.replace('',   '%20'。))读(); dh = hashlib.sha256(by).hexdigest();打开(   os.path.join(ip​​p,pf),' wb' ).write(by)if dh == h else None;   打印('错误验证下载(得到%s而不是%s),请尝试   手动安装' %(dh,h)如果dh!= h其他'请重新启动Sublime Text   完成安装')

答案 2 :(得分:0)

您可以按照以下步骤安装Babel软件包。

 1.open the url 
   -> https://packagecontrol.io/installation
 then copy the code in that page like this

导入urllib.request,os,hashlib; h ='6f4c264a24d933ce70df5dedcf1dcaee'+'ebe013ee18cced0ef93d5f746d80ef60'; pf ='Package Control.sublime-package'; ipp = sublime.installed_pa​​ckages_path(); urllib.request.install_opener(urllib.request.build_opener(urllib.request.ProxyHandler()));通过= urllib.request.urlopen('http://packagecontrol.io/'+ pf.replace('','%20'))。read(); dh = hashlib.sha256(by).hexdigest();如果dh!= h否则打开(os.path.join(ip​​p,pf),'wb',print('验证下载错误(用%s代替%s),请尝试手动安装'%(dh,h)) ).write(by)

注意:以上代码会经常更新

 2.Open Sublime text editor and "Goto View option and select Show Console"
 3.Paste the above code the console and press enter
 4.press command+shift+p to bring up the Command Palette
 5.In that search box type the text as "Package Control" and select the "Package Control:Install Package" option
 -> A new search box with options will come.
 6.Type the text “Babel” and select the Babel in the list. It will install the babel package.
 7.To Activate the Babel Syntax for the js file 
-> View -> Syntax -> Babel

Note: To open all of the folder files with the babel syntax

-> Goto View -> Syntax -> Open all with current extention as JavaScript -> Babel

答案 3 :(得分:0)

手动:对于Babel-sublime

如果由于某种原因控制台安装说明对您不起作用(例如在网络上具有代理),请执行以下步骤来手动安装Package Control:

1)首选项>浏览软件包

浏览一个文件夹,然后进入该文件夹 下载Package Control.sublime-package并将其复制到Installed Packages /目录中。

对于Sublime 2

import urllib2,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')

对于Sublime 3

import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

然后重新启动Sublime Text

想要更多的信息click here