博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用Theia——构建你自己的IDE
阅读量:4094 次
发布时间:2019-05-25

本文共 2991 字,大约阅读时间需要 9 分钟。

上一篇:Theia架构

构建你自己的IDE

红尘小说 https://wap.zuxs.net/

  本指南将教你如何构建你自己的Theia应用。

必要条件

  你需要安装node 10版本(译者:事实上最新的node稳定版即可):

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bashnvm install 10

  以及yarn:

npm install -g yarn

  还需要确保已安装python 2.x,可通过python --version来检查。

安装

  首先请创建一个空目录,然后切换到这个目录下:

mkdir my-appcd my-app

  在这个目录下创建package.json

{  "private": true,  "dependencies": {    "typescript": "latest",    "@theia/typescript": "next",    "@theia/navigator": "next",    "@theia/terminal": "next",    "@theia/outline-view": "next",    "@theia/preferences": "next",    "@theia/messages": "next",    "@theia/git": "next",    "@theia/file-search": "next",    "@theia/markers": "next",    "@theia/preview": "next",    "@theia/callhierarchy": "next",    "@theia/merge-conflicts": "next",    "@theia/search-in-workspace": "next",    "@theia/json": "next",    "@theia/textmate-grammars": "next",    "@theia/mini-browser": "next"  },  "devDependencies": {    "@theia/cli": "next"  }}

  简而言之,Theia应用程序和扩展包都是Node.js包。每一个包都包含一个package.json文件,里面列出了包的一些元数据,如name、version、运行时和构建时的依赖关系等。

  我们来看看这个包的内容:
  • nameversion被省略了,因为我们不打算将它作为一个依赖项来使用。同时它被标记为private,因为不打算将它发布为一个独立的Node.js包。
  • 我们在dependencies中列出了所有运行时依赖的扩展包,如@theia/navigator
    • 有些扩展包需要额外的工具来进行安装,例如,@theia/python需要Python Language Server来安装。此时你需要参考相应的文档。
    • 可以在这里查看所有已发布的扩展包。
  • 我们将@theis/cli列为构建时的依赖项,它提供了构建和运行应用程序的脚本。

构建

  首先,安装所有的依赖项。

yarn

  然后,使用Theia CLI来构建应用程序。

yarn theia build

  yarn在我们应用程序的上下文中查找由@theia/cli提供的theia可执行文件,然后使用theia执行build命令。这可能需要一些时间,因为默认情况下应用程序会在production模式下进行构建,即它会进行模糊处理和最小化处理。

运行

  构建完成之后,我们就可以启动应用程序:

yarn theia start

  你可以在命令的第一个参数中指定一个workspace路径,--hostname--port选项用来指定部署的主机名和端口号。例如下面的命令在指定的位置和端口号上打开/workspace

yarn theia start /my-workspace --hostname 0.0.0.0 --port 8080

  在终端中,你应该看到Theia应用程序已经启动并监听:

   打开浏览器并输入上面显示的地址,你就可以打开应用程序了。

故障排除

通过代理构建本地依赖项

  如果你通过代理运行yarn命令,在构建本地依赖项时有可能会遇到一些问题(如onigurma),例如下面的这个错误:

[4/4] Building fresh packages...[1/9]  XXXXX[2/9]  XXXXX[3/9]  XXXXX[4/9]  XXXXXerror /theiaide/node_modules/XXXXX: Command failed.Exit code: 1Command: node-gyp rebuildArguments:Directory: /theiaide/node_modules/XXXXXOutput:gyp info it worked if it ends with okgyp info using node-gyp@3.8.0gyp info using node@8.15.0 | linux | x64gyp http GET https://nodejs.org/download/release/v8.15.0/node-v8.15.0-headers.tar.gzgyp WARN install got an error, rolling back installgyp ERR! configure errorgyp ERR! stack Error: read ECONNRESETgyp ERR! stack at TLSWrap.onread (net.js:622:25)gyp ERR! System Linux 3.10.0-862.11.6.el7.x86_64gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"gyp ERR! cwd /theiaide/node_modules/XXXXXgyp ERR! node -v v8.15.0

  这是因为node-gyp在system/NPM的代理设置中不工作。如果遇到这种情况,可以通过错误堆栈中提供的链接下载node-headers文件(如上面例子中的https://nodejs.org/download/release/v8.15.0/node-v8.15.0-headers.tar.gz),然后使用下面的命令进行构建:

npm_config_tarball=/path/to/node-v8.15.0-headers.tar.gz yarn install

 

原文地址:https://theia-ide.org/docs/composing_applications/

转载地址:http://fmxii.baihongyu.com/

你可能感兴趣的文章
最小费用流 Bellman-Ford与Dijkstra 模板
查看>>
实现高性能纠删码引擎 | 纠删码技术详解(下)
查看>>
scala(1)----windows环境下安装scala以及idea开发环境下配置scala
查看>>
zookeeper(3)---zookeeper API的简单使用(增删改查操作)
查看>>
zookeeper(4)---监听器Watcher
查看>>
zookeeper(2)---shell操作
查看>>
mapReduce(3)---入门示例WordCount
查看>>
hbase(3)---shell操作
查看>>
hbase(1)---概述
查看>>
hbase(5)---API示例
查看>>
SSM-CRUD(1)---环境搭建
查看>>
SSM-CRUD(2)---查询
查看>>
SSM-CRUD (3)---查询功能改造
查看>>
Nginx(2)---安装与启动
查看>>
springBoot(5)---整合servlet、Filter、Listener
查看>>
C++ 模板类型参数
查看>>
C++ 非类型模版参数
查看>>
设计模式 依赖倒转原则 & 里氏代换原则
查看>>
DirectX11 光照
查看>>
图形学 图形渲染管线
查看>>