Node-gyp: Fatal error: 'utility' file not found, node-gyp rebuild

Created on 16 Oct 2018  ·  6Comments  ·  Source: nodejs/node-gyp

  • Node Version: v6.11.5 and 3.10.10
  • Platform: macOS Mojave Version: 10.14 (18A391) Xcode v9.4.1 and Xcode v10
  • Compiler: cc -v:
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Applications/Xcode_9.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  • Module: node-gyp rebuild

Verbose output (from npm or node-gyp):

> [email protected] install /Users/alex/Code/onedocway-rails/1dw-node/node_modules/contextify
> node-gyp rebuild

  CXX(target) Release/obj.target/contextify/src/contextify.o
In file included from ../src/contextify.cc:1:
In file included from /Users/alex/.node-gyp/6.11.5/include/node/node.h:42:
/Users/alex/.node-gyp/6.11.5/include/node/v8.h:21:10: fatal error: 'utility' file not found
#include <utility>
         ^~~~~~~~~
1 error generated.
make: *** [Release/obj.target/contextify/src/contextify.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/alex/.nvm/versions/node/v6.11.5/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:219:12)
gyp ERR! System Darwin 18.0.0
gyp ERR! command "/Users/alex/.nvm/versions/node/v6.11.5/bin/node" "/Users/alex/.nvm/versions/node/v6.11.5/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/alex/Code/onedocway-rails/1dw-node/node_modules/contextify
gyp ERR! node -v v6.11.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
/Users/alex/Code/onedocway-rails/1dw-node
├── UNMET PEER DEPENDENCY [email protected]
└── UNMET PEER DEPENDENCY [email protected]

npm WARN [email protected] requires a peer of [email protected] || 2.x but none was installed.
npm WARN [email protected] requires a peer of enzyme@^2.7.1 but none was installed.
npm WARN [email protected] requires a peer of [email protected] || 2.x but none was installed.
npm WARN [email protected] requires a peer of react@^0.14.7 but none was installed.
npm WARN [email protected] requires a peer of react@^0.14.7 but none was installed.
npm WARN [email protected] requires a peer of react@^0.14.0 but none was installed.
npm WARN [email protected] requires a peer of jquery@>=1.8.0 but none was installed.
npm ERR! Darwin 18.0.0
npm ERR! argv "/Users/alex/.nvm/versions/node/v6.11.5/bin/node" "/Users/alex/.nvm/versions/node/v6.11.5/bin/npm" "install"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the contextify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs contextify
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls contextify
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/alex/Code/onedocway-rails/1dw-node/npm-debug.log
npm ERR! code 1

Most helpful comment

with CXXFLAGS only it didn't work for me on macOs 10.15.1, but this worked (per https://github.com/nodejs/node-gyp/issues/1564#issuecomment-436609523):

CXXFLAGS="-mmacosx-version-min=10.9" LDFLAGS="-mmacosx-version-min=10.9" npm i

All 6 comments

/Users/alex/.node-gyp/6.11.5/include/node/common.gypi check out MacOS dev environment in this file

@yerassyl94 thx, it solved the problem!

Let's mention that it's about bumping macOS version like in your PR to i.e. 10.9
'MACOSX_DEPLOYMENT_TARGET': '10.9', # -mmacosx-version-min=10.9

@yerassyl94 could you explain what's the root cause here?

FTR, possible workaround:

For users:

env CXXFLAGS="-mmacosx-version-min=10.9" npm install

For addon authors:

add this to your bindings.gyp (but as mentioned above test)

  'xcode_settings': {
    'MACOSX_DEPLOYMENT_TARGET': '10.9',
  },

with CXXFLAGS only it didn't work for me on macOs 10.15.1, but this worked (per https://github.com/nodejs/node-gyp/issues/1564#issuecomment-436609523):

CXXFLAGS="-mmacosx-version-min=10.9" LDFLAGS="-mmacosx-version-min=10.9" npm i
Was this page helpful?
0 / 5 - 0 ratings