最近想要魔改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 node-gyp@3.6.2
gyp info using node@8.10.0 | 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
https://github.com/electron/electron
如果安装不了,需要对node_modules进行权限。
sudo chmod -R 777 node_modules/
然后在进行yarn install。从新走以上流程
如何切换node版本
(1)安装node版本管理模块n
sudo npm install n -g
sudo n stable
(3)安装最新版
sudo n latest
sudo n 版本号
(5) 查看已安装的版本
sudo n