Node gyp error make failed with exit code 2

I am trying to npm install my packages, and it seems a package named protagonist needs node-gyp I have literally tried everything I found online (issues here included) and still cant solve this. 2 ...
protagonist@0.17.2 install /Users/user/project/project/node_modules/protagonist
node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/CBlueprint.o
clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)
make: *** [Release/obj.target/libsnowcrash/snowcrash/src/CBlueprint.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/user/.nvm/versions/v8.11.1/lib/node_modules/npm/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 18.2.0
gyp ERR! command "/Users/user/.nvm/versions/v8.11.1/bin/node" "/Users/user/.nvm/versions/v8.11.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/user/project/project/node_modules/protagonist
gyp ERR! node -v v8.11.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm WARN marked-terminal@3.2.0 requires a peer of marked@^0.4.0 || ^0.5.0 || ^0.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN project No repository field.
npm WARN project No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! protagonist@0.17.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the protagonist@0.17.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2019-03-18T23_01_15_767Z-debug.log

Необходимо определиться с версией, которая вам нужна. Я предпочитаю ставить не новейшую версию Node.js, а последнюю LTS.

Установка в Elementary OS, Ubuntu:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

Установка в Debian:

curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get install -y nodejs

Инструкции под разные системы и для разных версий от разработчиков.

Проверка версий:

nodejs -v
npm -v

Если для проекта вы делаете:

npm install

И вылезает ошибка, вроде:

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/.../node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:311:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 5.3.0-42-generic
gyp ERR! command "/usr/bin/node" "/home/.../node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/.../node_modules/node-sass
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.10.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.10.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/d1mon/.npm/_logs/2020-03-31T05_52_52_174Z-debug.log

Необходимо удалить каталог node_modules и файл блокировки package-lock.json, очистить кэш и пробовать заново:

rm -rf node_modules package-lock.json
npm cache clean --force
npm install

Глобальная установка пакетов

Для глобальной установки пакетов в команду добавляется параметр -g. Но это не будет работать по умолчанию из-за проблем с правами доступа, поэтому предварительно требуется сделать следующее.

Создадим каталог для глобальных установок:

mkdir ~/.npm-global

Настройка npm на использование нового каталога:

npm config set prefix '~/.npm-global'

В файл ~/.profile необходимо добавить строку:

export PATH=~/.npm-global/bin:$PATH

В командной строке снова, для применения изменений:

source ~/.profile

На этом все, теперь можно устанавливать пакеты глобально.

I encountered a series of errors when I tried to run my existing Rails5 app in my freshly installed macOS Mojave.

$ bundle exec rails s

this generated some errors like, node not found, then I installed node using brew.

$ brew install node

then,

$ npm install yarn
$ yarn install 
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/john/projects/sifaris/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:196:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:256:12)
gyp ERR! System Darwin 18.5.0
gyp ERR! command "/usr/local/Cellar/node/12.1.0/bin/node" "/Users/john/projects/sifaris/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/john/projects/sifaris/node_modules/node-sass
gyp ERR! node -v v12.1.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
$ bundle exec rails s
=> Booting Puma
=> Rails 5.2.3 application starting in development
=> Run `rails server -h` for more startup options
error Lockfile does not contain pattern: "yarn@^1.15.2"
error Couldn't find an integrity file
error Found 2 errors.


========================================
  Your Yarn packages are out of date!
  Please run `yarn install --check-files` to update.
========================================

Solution

$ rm yarn.lock
$ yarn cache clean
$ yarn install
$ yarn install v1.15.2

now it installs all the dependencies properly

bundle exec rails s
=> Booting Puma
=> Rails 5.2.3 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.0-p0), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
yarn install v1.15.2

Понравилась статья? Поделить с друзьями:
  • Node express 500 error
  • Node exit process with error
  • Node error spawn unknown
  • No space left on device как исправить
  • No space between attributes как исправить