MacOS构建并运行VSCode源

时间:2018-04-12 02:25:01

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

我是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

有人可以帮忙吗? THX!

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

1 个答案:

答案 0 :(得分:0)

解决方法:

  1. 制作一个新文件夹,例如myvscode

  2. 在myvscode下,运行yarn init

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

  4. 在myvscode下,运行纱线

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

  6. 但仍然不知道如何解决原始问题。