Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve npm install errors on Mac

Tags:

npm-install

I purchased a template online for a Gatsby JS website and when I tried to use it, it worked, but then it just stopped. I tried opening the project in a new directory and it failed.

Currently I am unable to run npm install for the project and have no idea how to solve the issue.

The error messages are:

    npm ERR! code 1
    npm ERR! path /Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp
    npm ERR! command failed
    npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
    npm ERR! info sharp Using cached /Users/chistopherholder/.npm/_libvips/libvips-8.10.0-darwin-x64.tar.br
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using [email protected]
    npm ERR! gyp info using [email protected] | darwin | x64
    npm ERR! gyp info spawn /usr/bin/python2
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   '/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp/gyp/gyp_main.py',
    npm ERR! gyp info spawn args   'binding.gyp',
    npm ERR! gyp info spawn args   '-f',
    npm ERR! gyp info spawn args   'make',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp/build/config.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp/addon.gypi',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   '/Users/chistopherholder/.node-gyp/14.15.5/include/node/common.gypi',
    npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
    npm ERR! gyp info spawn args   '-Dvisibility=default',
    npm ERR! gyp info spawn args   '-Dnode_root_dir=/Users/chistopherholder/.node-gyp/14.15.5',
    npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp',
    npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/chistopherholder/.node-gyp/14.15.5/<(target_arch)/node.lib',
    npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp',
    npm ERR! gyp info spawn args   '-Dnode_engine=v8',
    npm ERR! gyp info spawn args   '--depth=.',
    npm ERR! gyp info spawn args   '--no-parallel',
    npm ERR! gyp info spawn args   '--generator-output',
    npm ERR! gyp info spawn args   'build',
    npm ERR! gyp info spawn args   '-Goutput_dir=.'
    npm ERR! gyp info spawn args ]
    npm ERR! No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
    npm ERR! 
    npm ERR! No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
    npm ERR! 
    npm ERR! No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
    npm ERR! 
    npm ERR! gyp: No Xcode or CLT version detected!
    npm ERR! gyp ERR! configure error 
    npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
    npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp/lib/configure.js:345:16)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
    npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
    npm ERR! gyp ERR! System Darwin 20.3.0
    npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/.bin/node-gyp" "rebuild"
    npm ERR! gyp ERR! cwd /Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp
    npm ERR! gyp ERR! node -v v14.15.5
    npm ERR! gyp ERR! node-gyp -v v3.8.0
    npm ERR! gyp ERR! not ok

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/chistopherholder/.npm/_logs/2021-03-05T00_04_39_680Z-debug.log

I opened up the debug.log but it is a 1787 lines of code that I don't quite understand. I also tried sudo npm install.

How can I solve these issues?

Any hint in the right direction would be much appreciated. I am usually working with django and not react so I am a bit clueless here.

like image 548
Chris Avatar asked Mar 05 '21 00:03

Chris


People also ask

Why is npm install failing?

code 1 error usually occurs when you run the npm install command. This cause of this error is that one of the dependencies you define in your package. json file fails to be installed properly on your computer. This means that npm fails to install the node-sass module that's added as a dependency to the n-app project.


1 Answers

It may not be the same issue in every case, but whenever I see the npm ERR! gyp: No Xcode or CLT version detected! I have to remove xcode and reinstall, then the error goes away. My best guess is that it's an issue with Node and/or MacOs updates that cause conflicts.

When this happens you can first try:

sudo xcode-select --reset

And if that doesn't work (which it never has for me) you can then try:

sudo rm -rf $(xcode-select -print-path) && xcode-select --install
like image 200
eper Avatar answered Oct 20 '22 02:10

eper