简体   繁体   中英

Unable to npm install on mac without Xcode?

I am trying to run npm install on my mac machine. When do i get a bunch of errors as below

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Traceback (most recent call last):
  File "/Users/mac/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "/Users/mac/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "/Users/mac/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 538, in main
    return gyp_main(args)
  File "/Users/mac/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 523, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "/Users/mac/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2170, in GenerateOutput
    part_of_all=qualified_target in needed_targets)
  File "/Users/mac/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 795, in Write
    self.Pchify))
  File "/Users/mac/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1190, in WriteSources
    cflags = self.xcode_settings.GetCflags(configname)
  File "/Users/mac/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 551, in GetCflags
    archs = self.GetActiveArchs(self.configname)
  File "/Users/mac/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py", line 420, in GetActiveArchs

I know i can get rid of this by installing Xcode and setting the path. But somehow i don't want to use Xcode.I have installed command line tools by

xcode-select --install

And set it's path but still i get this error. Anyone having any idea ?

You can't install NPM on your computer via command line until you have installed it before. More simply put you can only update NPM via command line you can't install it initially. Download Node.JS from here: NodeJs . It's comes with NPM. Then try SUDO if you are running a global (-g) install.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM