【问题标题】:How to install Babel using Package Control on Sublime Text 3?如何在 Sublime Text 3 上使用 Package Control 安装 Babel?
【发布时间】:2015-09-22 17:04:12
【问题描述】:

我想安装Babel。我使用的是 Mac,我已经新安装了 Sublime Text 3 和 Package Controll。所以我尝试 cmd+shift+p 打开 Package Controll 并输入“Install”但什么也没有出现。我在关注this link。我需要 Babel 来突出显示 React 语法。

【问题讨论】:

  • 好吧,因为我误解了,您确实可以毫无问题地打开命令面板,对吧?
  • 是的,它看起来像一个搜索框。我假设那是命令调色板。我还尝试通过转到 Tools --> Command Palette 手动打开命令面板,它会打开看起来像搜索框的同一个灰色框。
  • 没错。如果您输入 Package Control,您会看到任何相关结果吗?
  • 不。当我输入 Package ControlInstall 时没有出现相关搜索

标签: macos sublimetext3 babeljs


【解决方案1】:

您可以按照以下步骤安装 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 = '包控制.sublime-package'; 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(by).hexdigest(); print('验证下载时出错(得到 %s 而不是 %s),请尝试手动安装' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).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

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

    • 当我尝试运行this link 中的第二个代码块时,出现此错误:ImportError: No module named 'urllib2'
    • 你还有其他的包吗? Cmd+shift+p 和列表中的类型。应该给其他包。您是否也尝试过重新安装 sublime?
    【解决方案3】:

    遇到同样的问题,在我的情况下,我必须先安装包控件,我使用“简单安装”方法,将Package.io 中的代码粘贴到控制台(查看 > 显示控制台)。

    对于崇高 3:

    导入 urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = '包 Control.sublime-package'; 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(by).hexdigest(); print('验证下载错误(得到 %s 而不是 %s),如果 dh != h,请尝试手动安装'% (dh, h)) else open(os.path.join(ipp, pf), 'wb').write(by)

    对于 Sublime 2:

    导入 urllib2,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = '包 Control.sublime-package'; 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')).read(); dh = hashlib.sha256(by).hexdigest();打开( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('验证下载时出错(得到 %s 而不是 %s),请尝试 手动安装' % (dh, h) if dh != h else '请重启 Sublime Text 完成安装')

    【讨论】:

      【解决方案4】:

      手动:对于 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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-11
        • 1970-01-01
        • 2015-02-07
        • 2013-11-01
        • 2013-09-05
        • 1970-01-01
        相关资源
        最近更新 更多