【问题标题】:MacOS build and run VSCode sourceMacOS 构建和运行 VSCode 源码
【发布时间】:2018-09-22 01:03:20
【问题描述】:

我是 NodeJS 的新手,尝试在 MacOS 上构建和运行 Visual Studio 代码源,但在 vscode 源路径下运行“yarn install”后安装依赖项的步骤出现错误。这是我得到的:

>yarn install
yarn install v1.5.1
$ node build/npm/preinstall.js
[1/4] ????  Resolving packages...
[2/4] ????  Fetching packages...
info windows-foreground-love@0.1.0: The platform "darwin" is incompatible with this module.
info "windows-foreground-love@0.1.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info windows-mutex@0.2.0: The platform "darwin" is incompatible with this module.
info "windows-mutex@0.2.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info windows-process-tree@0.2.1: The platform "darwin" is incompatible with this module.
info "windows-process-tree@0.2.1" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] ????  Linking dependencies...
[4/4] ????  Building fresh packages...
[1/14] ⡀ gc-signals:  ^
[6/14] ⡀ native-watchdog: ^
[3/14] ⡀ keytar: CXX(target) Release/obj.target/keytar/src/async.o
[4/14] ⡀ native-is-elevated: 6 errors generated.
error An unexpected error occurred: "/Users/xxx/Documents/GitHub/vscode/node_modules/native-is-elevated: Command failed.
Exit code: 1
Command: sh
Arguments: -c node-gyp rebuild
Directory: /Users/xxx/Documents/GitHub/vscode/node_modules/native-is-elevated
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.11.1 | darwin | x64
gyp info spawn /usr/bin/python
gyp info spawn args [ '/Users/xxx/.config/yarn/global/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/GitHub/vscode/node_modules/native-is-elevated/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/xxx/.config/yarn/global/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/xxx/.node-gyp/iojs-1.7.12/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/iojs-1.7.12',
gyp info spawn args   '-Dnode_gyp_dir=/Users/xxx/.config/yarn/global/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/xxx/.node-gyp/iojs-1.7.12/<(target_arch)/iojs.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/xxx/Documents/GitHub/vscode/node_modules/native-is-elevated',
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 info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/is-elevated/src/is-elevated.o
In file included from ../src/is-elevated.cc:1:
In file included from /Users/xxx/.node-gyp/iojs-1.7.12/src/node.h:42:
/Users/xxx/.node-gyp/iojs-1.7.12/deps/v8/include/v8.h:15:2: error: unterminated conditional directive
#ifndef INCLUDE_V8_H_
 ^
/Users/xxx/.node-gyp/iojs-1.7.12/deps/v8/include/v8.h:8533:10: error: unknown type name 'c'
  static c
         ^
In file included from ../src/is-elevated.cc:1:
/Users/xxx/.node-gyp/iojs-1.7.12/src/node.h:76:1: error: expected member name or ';' after declaration specifiers
struct uv_loop_s;
^
In file included from ../src/is-elevated.cc:1:
In file included from /Users/xxx/.node-gyp/iojs-1.7.12/src/node.h:42:
/Users/xxx/.node-gyp/iojs-1.7.12/deps/v8/include/v8.h:8494:7: error: missing '}' at end of definition of 'v8::internal::Internals'
class Internals {
      ^
/Users/xxx/.node-gyp/iojs-1.7.12/src/node.h:80:1: note: still within definition of 'v8::internal::Internals' here
namespace node {
^
../src/is-elevated.cc:57:2: error: expected '}'
}
 ^
/Users/xxx/.node-gyp/iojs-1.7.12/deps/v8/include/v8.h:8409:20: note: to match this '{'
namespace internal {
                   ^
../src/is-elevated.cc:57:2: error: expected '}'
}
 ^
/Users/xxx/.node-gyp/iojs-1.7.12/deps/v8/include/v8.h:64:14: note: to match this '{'
namespace v8 {
             ^
6 errors generated.
make: *** [Release/obj.target/is-elevated/src/is-elevated.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/xxx/.config/yarn/global/node_modules/node-gyp/lib/build.js:258:23)
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.5.0
gyp ERR! command \"/opt/local/bin/node\" \"/Users/xxx/.yarn/bin/node-gyp\" \"rebuild\"
gyp ERR! cwd /Users/xxx/Documents/GitHub/vscode/node_modules/native-is-elevated
gyp ERR! node -v v8.11.1

有人可以帮忙吗?谢谢!

PS:我在 MacPorts 中安装了 yarn,同时安装了 nodejs6。我停用了 nodejs6 并使用 MacPorts 安装了 nodejs8。在所有这些之前,我手动安装了 NodeJS 并下载了包。 Python 活动版本是 2.7.10,安装了 python3。 MacOS High Sierra 10.13.4

【问题讨论】:

  • 首先为什么要从源代码构建 VSCode?其次,你为什么使用 macports 而不是 homebrew?第三,这是编译原生二进制文件native-is-elevated 的问题。你安装了 XCode 吗?
  • Xcode 和命令行工具已安装。

标签: javascript node.js macos visual-studio-code yarnpkg


【解决方案1】:

解决方法:

  1. 新建一个文件夹,比如 myvscode

  2. 在myvscode下,运行yarn init

  3. 将 package.json 从 vscode 复制到 myvscode

  4. 在myvscode下,运行yarn

  5. 将node_modules以外的其他文件从vscode复制到myvscode

但仍然不知道如何解决原来的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-06
    • 1970-01-01
    • 2021-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-12
    • 1970-01-01
    相关资源
    最近更新 更多