vscode-源码分析路程(一)

最近想要魔改vscode结果编译是遇到

error /Users/xxx/Documents/vscode/remote/node_modules/spdlog: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments: 
Directory: /Users/xxx/Documents/vscode/remote/node_modules/spdlog
Output:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp info spawn /usr/bin/python
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/xxx/Documents/vscode/remote/node_modules/spdlog/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/xxx/.node-gyp/10.11.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/xxx/.node-gyp/10.11.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/v_chicunxiang/.node-gyp/10.11.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/xxx/Documents/vscode/remote/node_modules/spdlog',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp: name 'build_v8_with_gn' is not defined while evaluating condition 'build_v8_with_gn == "true"' in binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/xxx/Documents/vscode/remote/node_modules/spdlog

一直没有发现问题在哪里。

最后确定是node版本问题。升级10.0.0就ok了

下面说一下vscode的编译流程

1. 克隆代码

git clone https://github.com/microsoft/vscode.git

2. 进入目录后执行yarn

cd /xxx/vscode
yarn install

3. 运行

Run

To test the changes you launch a development version of VS Code on the workspace vscode, which you are currently editing.

macOS and Linux

./scripts/code.sh

Windows

.\scripts\code.bat

运行遇到的坑

需要安装elecrton

扫描二维码关注公众号,回复: 10818581 查看本文章

https://github.com/electron/electron

如果安装不了,需要对node_modules进行权限。

sudo chmod -R 777 node_modules/

 然后在进行yarn install。从新走以上流程

如何切换node版本

(1)安装node版本管理模块n

sudo npm install n -g

(2)安装稳定版

sudo n stable

(3)安装最新版

sudo n latest

(4) 版本降级/升级

sudo n 版本号

  (5)  查看已安装的版本

sudo n
发布了74 篇原创文章 · 获赞 22 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/ci250454344/article/details/100774423
今日推荐