xcode-select:错误:工具“xcodebuild”需要 Xcode

jav*_*sel 3 node.js npm angular

我正在尝试将我的 Angular 应用程序从v4.4.6 迁移到 v14.0.4。我已成功执行以下步骤:

\n
 % rm -rf node_modules\n % npm update --loglevel verbose\n % npm install --loglevel verbose\n % nvm install 8.9.4\n % nvm use 8.9.4\n % nvm alias default 8.9.4\n % npm uninstall -g @angular/cli\n % npm install -g @angular/cli@6.2.9 --loglevel verbose\n % npm install --save-dev @angular/cli@6.2.9 --loglevel verbose\n
Run Code Online (Sandbox Code Playgroud)\n

但是当我尝试运行以下命令行时,我收到了此错误:

\n
 % NG_DISABLE_VERSION_CHECK=1 npx @angular/cli@6.2.9 update @angular/cli@6.2.9 --loglevel verbose\n    xcode-select: error: tool \'xcodebuild\' requires Xcode, but active developer directory \'/Library/Developer/CommandLineTools\' is a command line tools instance\n    \n    Traceback (most recent call last):\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>\n        sys.exit(gyp.script_main())\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main\n        return main(sys.argv[1:])\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main\n        return gyp_main(args)\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 523, in gyp_main\n        generator.GenerateOutput(flat_list, targets, data, params)\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2170, in GenerateOutput\n        part_of_all=qualified_target in needed_targets)\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 817, in Write\n        mac_bundle_deps, extra_outputs, part_of_all)\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1453, in WriteTarget\n        lambda p: Sourceify(self.Absolutify(p)))\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 809, in GetLdflags\n        archs = self.GetActiveArchs(self.configname)\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 420, in GetActiveArchs\n        xcode_archs_default = GetXcodeArchsDefault()\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 118, in GetXcodeArchsDefault\n        xcode_version, _ = XcodeVersion()\n      File "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 1265, in XcodeVersion\n        version = re.match(r\'(\\d\\.\\d\\.?\\d*)\', version).groups()[0]\n    AttributeError: \'NoneType\' object has no attribute \'groups\'\n    gyp ERR! configure error \n    gyp ERR! stack Error: `gyp` failed with exit code: 1\n    gyp ERR! stack     at ChildProcess.onCpExit (/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)\n    gyp ERR! stack     at emitTwo (events.js:126:13)\n    gyp ERR! stack     at ChildProcess.emit (events.js:214:7)\n    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)\n    gyp ERR! System Darwin 21.3.0\n    gyp ERR! command "/Users/userx/.nvm/versions/node/v8.9.4/bin/node" "/Users/userx/.nvm/versions/node/v8.9.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"\n    gyp ERR! cwd /Users/userx/.npm/_npx/22018/lib/node_modules/@angular/cli/node_modules/fsevents\n    gyp ERR! node -v v8.9.4\n    gyp ERR! node-gyp -v v3.6.2\n    gyp ERR! not ok \n
Run Code Online (Sandbox Code Playgroud)\n

我仔细检查了 xCode,发现它已经安装在我的 mac 上。

\n

欲了解信息:

\n
% ng --version\n\n     _                      _                 ____ _     ___\n    / \\   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|\n   / \xe2\x96\xb3 \\ | \'_ \\ / _` | | | | |/ _` | \'__|   | |   | |    | |\n  / ___ \\| | | | (_| | |_| | | (_| | |      | |___| |___ | |\n /_/   \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_|       \\____|_____|___|\n                |___/\n    \n\nAngular CLI: 6.2.9\nNode: 8.9.4\nOS: darwin x64\nAngular: 4.4.7\n... animations, common, compiler, compiler-cli, core, forms\n... http, language-service, platform-browser\n... platform-browser-dynamic, router, tsc-wrapped\n\nPackage                      Version\n------------------------------------------------------\n@angular-devkit/architect    0.8.9\n@angular-devkit/core         0.8.9\n@angular-devkit/schematics   0.8.9\n@angular/cli                 6.2.9\n@schematics/angular          0.8.9\n@schematics/update           0.8.9\nrxjs                         5.5.12\ntypescript                   2.4.2\n
Run Code Online (Sandbox Code Playgroud)\n

任何想法如何解决这个问题请。

\n

jav*_*sel 8

终于找到了我的问题的解决方案:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Run Code Online (Sandbox Code Playgroud)

来源