nodejs / node-addon-api

Module for using Node-API from C++
MIT License
2.18k stars 459 forks source link

gyp: binding.gyp not found while trying to load binding.gyp #1028

Closed amadrzyk closed 3 years ago

amadrzyk commented 3 years ago

Hello! I'm trying to deploy my NextJS app onto Netlify, but I'm getting the following build/deploy errors:

1:32:14 PM:   Error message
1:32:14 PM:   Error while installing dependencies in /opt/build/repo/.netlify/plugins/
1:32:14 PM:   npm WARN optional dep failed, continuing fsevents@2.3.2
1:32:14 PM: ​
1:32:14 PM:   > node-addon-api@3.2.1 install /opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/node_modules/sharp/node_modules/node-addon-api
1:32:14 PM:   > node-gyp rebuild
1:32:14 PM: ​
1:32:14 PM:   (node:1592) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
1:32:14 PM:   (Use `node --trace-deprecation ...` to show where the warning was created)
1:32:14 PM:   gyp: binding.gyp not found (cwd: /opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/node_modules/sharp/node_modules/node-addon-api) while trying to load binding.gyp
1:32:14 PM:   gyp ERR! configure error
1:32:14 PM:   gyp ERR! stack Error: `gyp` failed with exit code: 1
1:32:14 PM:   gyp ERR! stack     at ChildProcess.onCpExit (/opt/build/repo/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
1:32:14 PM:   gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
1:32:14 PM:   gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
1:32:14 PM:   gyp ERR! System Linux 4.19.167+
1:32:14 PM:   gyp ERR! command "/opt/build/repo/node_modules/node/bin/node" "/opt/build/repo/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
1:32:14 PM:   gyp ERR! cwd /opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/node_modules/sharp/node_modules/node-addon-api
1:32:14 PM:   gyp ERR! node -v v16.5.0
1:32:14 PM:   gyp ERR! node-gyp -v v3.6.0
1:32:14 PM:   gyp ERR! not ok

and a little lower in the logs:

1:32:14 PM:   npm ERR! Linux 4.19.167+
1:32:14 PM:   npm ERR! argv "/opt/build/repo/node_modules/node/bin/node" "/opt/build/repo/node_modules/.bin/npm" "install" "--no-progress" "--no-audit" "--no-fund" "--save-exact" "@netlify/plugin-nextjs@3.7.1"
1:32:14 PM:   npm ERR! node v16.5.0
1:32:14 PM:   npm ERR! npm  v2.15.12
1:32:14 PM:   npm ERR! code ELIFECYCLE
1:32:14 PM: ​
1:32:14 PM:   npm ERR! node-addon-api@3.2.1 install: `node-gyp rebuild`
1:32:14 PM:   npm ERR! Exit status 1
1:32:14 PM:   npm ERR!
1:32:14 PM:   npm ERR! Failed at the node-addon-api@3.2.1 install script 'node-gyp rebuild'.
1:32:14 PM:   npm ERR! This is most likely a problem with the node-addon-api package,
1:32:14 PM:   npm ERR! not with npm itself.
1:32:14 PM:   npm ERR! Tell the author that this fails on your system:
1:32:14 PM:   npm ERR!     node-gyp rebuild
1:32:14 PM:   npm ERR! You can get information on how to open an issue for this project with:
1:32:14 PM:   npm ERR!     npm bugs node-addon-api
1:32:14 PM:   npm ERR! Or if that isn't available, you can get their info via:
  npm ERR!
1:32:14 PM:   npm ERR!     npm owner ls node-addon-api
1:32:14 PM:   npm ERR! There is likely additional logging output above.
1:32:14 PM: ​
1:32:17 PM: Creating deploy upload records
1:32:14 PM:   npm ERR! Please include the following file with any support request:
1:32:14 PM: ​
1:32:14 PM:   Resolved config
1:32:14 PM:   build:
1:32:14 PM:     command: next build
1:32:14 PM:     commandOrigin: ui
1:32:14 PM:     publish: /opt/build/repo
1:32:14 PM:     publishOrigin: default
1:32:14 PM:   plugins:
1:32:14 PM:     - inputs: {}
1:32:14 PM:       origin: ui
1:32:14 PM:       package: '@netlify/plugin-nextjs'

Any ideas on how to proceed? 🙇

NickNaso commented 3 years ago

Hi @amadrzyk, is your repo public? Could you post your build / deploy configuration? Is the folder that contains your project has the name with a space character (es. "my project")? This issue is correlate to https://github.com/netlify/netlify-plugin-nextjs/issues/563 for Essential Next.js Build Plugin.

amadrzyk commented 3 years ago

Hi @NickNaso! Unfortunately my repo is not public, but it is one word (no spaces). Here's my package.json, which is basically the only thing in our build configuration (other than env variables):

{
    "name": "myproject",
    "version": "1.0.0",
    "private": true,
    "scripts": {
        "dev": "export NODE_OPTIONS=\"--max-old-space-size=4096\" && export NEXT_PUBLIC_ENVIRONMENT=\"development\" && next dev",
        "build": "next build",
        "start": "next start",
    },
    "dependencies": {
        "@brainhubeu/react-carousel": "^1.19.26",
        "@bugsnag/js": "^7.3.0",
        "@bugsnag/plugin-react": "^7.3.1",
        "@fingerprintjs/fingerprintjs": "^3.0.5",
        "@firebase/storage": "^0.3.35",
        "@google-cloud/storage": "^5.5.0",
        "@material-ui/core": "^4.11.0",
        "@material-ui/icons": "^4.11.2",
        "@sendgrid/mail": "^7.2.6",
        "@sentry/react": "^6.2.0",
        "@sentry/tracing": "^6.2.0",
        "@stripe/react-stripe-js": "^1.1.2",
        "@stripe/stripe-js": "^1.9.0",
        "@types/gapi": "^0.0.39",
        "ace-builds": "^1.4.12",
        "axios": "^0.19.2",
        "bootstrap": "^4.5.3",
        "classnames": "^2.2.6",
        "clipboard": "^2.0.6",
        "clsx": "^1.1.1",
        "cookie": "^0.4.1",
        "cors": "^2.8.5",
        "dotenv": "^8.2.0",
        "emoji-mart": "^3.0.1",
        "fast-crc32c": "^2.0.0",
        "file-loader": "^6.2.0",
        "firebase": "^7.14.3",
        "firebase-admin": "^8.12.1",
        "firebase-functions": "^3.7.0",
        "fs": "^0.0.1-security",
        "gapi-script": "^1.0.2",
        "googleapis": "^55.0.0",
        "immutability-helper": "^3.0.2",
        "js-md5": "^0.7.3",
        "jwt-decode": "^2.2.0",
        "latest": "^0.2.0",
        "lodash": "^4.17.20",
        "micro": "^9.3.4",
        "moment": "^2.25.3",
        "moment-timezone": "^0.5.33",
        "mui-datatables": "^3.7.4",
        "next": "^11.0.1",
        "next-absolute-url": "^1.2.2",
        "node": "^16.1.0",
        "node-addon-api": "^4.0.0",
        "nookies": "^2.3.0",
        "objects-to-csv": "^1.3.6",
        "query-string": "^6.12.1",
        "rc-progress": "^3.1.4",
        "re-resizable": "^6.5.0",
        "react": "^17.0.2",
        "react-ace": "9.3.0",
        "react-adsense": "^0.1.0",
        "react-async-script-loader": "^0.3.0",
        "react-beautiful-dnd": "^13.0.0",
        "react-bootstrap": "^1.3.0",
        "react-clipboard.js": "^2.0.16",
        "react-color": "^2.18.1",
        "react-confetti": "^5.1.0",
        "react-datepicker": "^3.0.0",
        "react-dom": "16.13.1",
        "react-dropzone": "^11.2.4",
        "react-ga": "^3.0.0",
        "react-google-autocomplete": "^1.2.6",
        "react-hotjar": "^2.2.1",
        "react-iframe": "^1.8.0",
        "react-inline-script": "^1.2.0",
        "react-input-range": "^1.3.0",
        "react-ionicons": "^3.1.4",
        "react-loading-skeleton": "^2.1.1",
        "react-no-ssr": "^1.1.0",
        "react-places-autocomplete": "^7.2.1",
        "react-responsive-masonry": "^2.1.0",
        "react-toastify": "^6.0.5",
        "react-twitter-widgets": "^1.9.5",
        "semantic-ui-css": "^2.4.1",
        "semantic-ui-react": "^1.2.1",
        "sib-api-v3-sdk": "^8.1.1",
        "stripe": "^8.90.0",
        "uniqid": "^5.2.0",
        "uuid": "^8.3.2",
        "xhr2": "^0.2.0"
    },
    "prettier": {
        "useTabs": true,
        "tabWidth": 4,
        "printWidth": 80
    },
    "devDependencies": {
        "eslint-plugin-sort-imports-es6-autofix": "^0.5.0",
        "prettier": "^2.0.5",
        "prop-types": "^15.7.2",
        "typescript": "^3.9.3"
    }
}

also tsconfig.json (not sure if relevant):

{
    "compilerOptions": {
        "target": "es5",
        "lib": ["dom", "dom.iterable", "esnext"],
        "allowJs": true,
        "skipLibCheck": true,
        "strict": false,
        "forceConsistentCasingInFileNames": true,
        "noEmit": true,
        "esModuleInterop": true,
        "module": "esnext",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "jsx": "preserve",
        "types": [
            "gapi"
        ]
    },
    "exclude": ["node_modules"],
    "include": ["next-env.d.ts", "pages/*.ts"]
}
amadrzyk commented 3 years ago

Small bump 🙇‍♂️ @NickNaso

NickNaso commented 3 years ago

Hi @amadrzyk, I tried to reproduce your error deploying the Netifly startter kit https://github.com/NickNaso/next-netlify-starter but I cannot able to obtain your error.

lovell commented 3 years ago

@amadrzyk It looks like you're using outdated versions of npm (v2.15.12) and node-gyp (v3.6.0), both released in March 2017, please can you upgrade.

mhdawson commented 3 years ago

Since there seems to be answers and no response for a few months I'm going to close this. @amadrzyk please let us know if that was not the right thing to do.