Shopify / shopify-api-js

Shopify Admin API Library for Node. Accelerate development with support for authentication, graphql proxy, webhooks
MIT License
941 stars 392 forks source link

Not able to install shopify-node-api #400

Closed gaurav-pachar closed 1 year ago

gaurav-pachar commented 2 years ago

Issue summary

unable to install shopify-api with, npm i @shopify/shopify-api

Expected behavior

dependency should get installed

Actual behavior

while executing npm i @shopify/shopify-api, the process gets interrupted at reify:@shopify/shopify-api: timing reifyNode:node_modules/@redis/client Completed in 361ms

the whole error log after interruption is:

npm i @shopify/shopify-api
npm ERR! code 1
npm ERR! path /Users/gauravpachar/untitled folder/node_modules/sqlite3
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
npm ERR!   LIBTOOL-STATIC Release/nothing.a
npm ERR!   ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3380400/sqlite3.c
npm ERR!   TOUCH Release/obj.target/deps/action_before_build.stamp
npm ERR!   CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3380400/sqlite3.o
npm ERR!   LIBTOOL-STATIC Release/sqlite3.a
npm ERR!   CXX(target) Release/obj.target/node_sqlite3/src/backup.o
npm ERR! Failed to execute '/opt/homebrew/Cellar/node/18.2.0/bin/node /opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/gauravpachar/untitled folder/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/gauravpachar/untitled folder/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.9
npm ERR! node-pre-gyp info using node@18.2.0 | darwin | arm64
npm ERR! node-pre-gyp info check checked for "/Users/gauravpachar/untitled folder/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/TryGhost/node-sqlite3/releases/download/v5.0.8/napi-v6-darwin-unknown-arm64.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/TryGhost/node-sqlite3/releases/download/v5.0.8/napi-v6-darwin-unknown-arm64.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for sqlite3@5.0.8 and node@18.2.0 (node-v108 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/TryGhost/node-sqlite3/releases/download/v5.0.8/napi-v6-darwin-unknown-arm64.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@18.2.0 | darwin | arm64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@18.2.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.10.4 found at "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3"
npm ERR! gyp info spawn /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/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/gauravpachar/untitled folder/node_modules/sqlite3/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/gauravpachar/Library/Caches/node-gyp/18.2.0/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/gauravpachar/Library/Caches/node-gyp/18.2.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/gauravpachar/Library/Caches/node-gyp/18.2.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/gauravpachar/untitled folder/node_modules/sqlite3',
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! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@18.2.0 | darwin | arm64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
npm ERR! /bin/sh: folder/node_modules/sqlite3/build/Release/lib.host:/Users/gauravpachar/untitled: No such file or directory
npm ERR! clang: error: no such file or directory: 'folder/node_modules/node-addon-api'
npm ERR! make: *** [Release/obj.target/node_sqlite3/src/backup.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.5.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/18.2.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/gauravpachar/untitled folder/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/gauravpachar/untitled folder/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=6" "--node_napi_label=napi-v6"
npm ERR! gyp ERR! cwd /Users/gauravpachar/untitled folder/node_modules/sqlite3
npm ERR! gyp ERR! node -v v18.2.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute '/opt/homebrew/Cellar/node/18.2.0/bin/node /opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/gauravpachar/untitled folder/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/gauravpachar/untitled folder/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=6 --node_napi_label=napi-v6' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/gauravpachar/untitled folder/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1090:16)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! node-pre-gyp ERR! System Darwin 21.5.0
npm ERR! node-pre-gyp ERR! command "/opt/homebrew/Cellar/node/18.2.0/bin/node" "/Users/gauravpachar/untitled folder/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /Users/gauravpachar/untitled folder/node_modules/sqlite3
npm ERR! node-pre-gyp ERR! node -v v18.2.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.9
npm ERR! node-pre-gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/gauravpachar/.npm/_logs/2022-06-02T17_45_52_071Z-debug-0.log

this error does not occur if I create a boilerplate project using shopify app create node with shopify CLI

Steps to reproduce the problem

  1. npm init -y
  2. npm i @shopify/shopify-api

device: Macbook air M1 OS: MacOS Monterey(version 12.4) Node Version: 18.2.0 npm version: 8.9.0

sagrawal31 commented 2 years ago

I think this matches my issue so commenting here

We are using this @shopify/shopify-api in our NestJS application. After upgrading the library to v3.1.3 (from ^3.0.0), while building, we are getting this error-

ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>
 @ ./node_modules/@mapbox/node-pre-gyp/lib/ sync ^\.\/.*$ ./util/nw-pre-gyp/index.html
 @ ./node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js 86:13-36 291:36-53
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:15-46
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:16-47
 @ ./node_modules/@shopify/shopify-api/dist/auth/session/storage/sqlite.js 5:40-58
 @ ./node_modules/@shopify/shopify-api/dist/context.js 7:15-55
 @ ./node_modules/@shopify/shopify-api/dist/index.js 5:16-36
 @ ./apps/client-app/src/services/shopify/shopify-webhook-api.service.ts 16:22-53
 @ ./apps/client-app/src/artifacts.module.ts 70:38-95
 @ ./apps/client-app/src/app.module.ts 19:27-56
 @ ./apps/client-app/src/main.ts 9:21-44

ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js 43:20-42
Module not found: Error: Can't resolve 'mock-aws-s3' in '/Users/shashank/Projects/cooee/node-backend-app/node_modules/@mapbox/node-pre-gyp/lib/util'
 @ ./node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js 15:21-62
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:15-46
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:16-47
 @ ./node_modules/@shopify/shopify-api/dist/auth/session/storage/sqlite.js 5:40-58
 @ ./node_modules/@shopify/shopify-api/dist/context.js 7:15-55
 @ ./node_modules/@shopify/shopify-api/dist/index.js 5:16-36
 @ ./apps/client-app/src/services/shopify/shopify-webhook-api.service.ts 16:22-53
 @ ./apps/client-app/src/artifacts.module.ts 70:38-95
 @ ./apps/client-app/src/app.module.ts 19:27-56
 @ ./apps/client-app/src/main.ts 9:21-44

ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js 76:14-32
Module not found: Error: Can't resolve 'aws-sdk' in '/Users/shashank/Projects/cooee/node-backend-app/node_modules/@mapbox/node-pre-gyp/lib/util'
 @ ./node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js 15:21-62
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:15-46
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:16-47
 @ ./node_modules/@shopify/shopify-api/dist/auth/session/storage/sqlite.js 5:40-58
 @ ./node_modules/@shopify/shopify-api/dist/context.js 7:15-55
 @ ./node_modules/@shopify/shopify-api/dist/index.js 5:16-36
 @ ./apps/client-app/src/services/shopify/shopify-webhook-api.service.ts 16:22-53
 @ ./apps/client-app/src/artifacts.module.ts 70:38-95
 @ ./apps/client-app/src/app.module.ts 19:27-56
 @ ./apps/client-app/src/main.ts 9:21-44

ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js 112:15-30
Module not found: Error: Can't resolve 'nock' in '/Users/shashank/Projects/cooee/node-backend-app/node_modules/@mapbox/node-pre-gyp/lib/util'
 @ ./node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js 15:21-62
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:15-46
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:16-47
 @ ./node_modules/@shopify/shopify-api/dist/auth/session/storage/sqlite.js 5:40-58
 @ ./node_modules/@shopify/shopify-api/dist/context.js 7:15-55
 @ ./node_modules/@shopify/shopify-api/dist/index.js 5:16-36
 @ ./apps/client-app/src/services/shopify/shopify-webhook-api.service.ts 16:22-53
 @ ./apps/client-app/src/artifacts.module.ts 70:38-95
 @ ./apps/client-app/src/app.module.ts 19:27-56
 @ ./apps/client-app/src/main.ts 9:21-44

ERROR in ./node_modules/node-gyp/lib/Find-VisualStudio.cs 9:6
Module parse failed: Unexpected token (9:6)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| // This script needs to be compatible with PowerShell v2 to run on Windows 2008R2 and Windows 7.
| 
> using System;
| using System.Text;
| using System.Runtime.InteropServices;
 @ ./node_modules/node-gyp/lib/ sync ^\.\/.*$ ./Find-VisualStudio.cs
 @ ./node_modules/node-gyp/lib/node-gyp.js 41:13-36 191:36-53
 @ ./node_modules/@mapbox/node-pre-gyp/lib/util/compile.js 31:26-53
 @ ./node_modules/@mapbox/node-pre-gyp/lib/ sync ^\.\/.*$ ./util/compile.js ./util/compile
 @ ./node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js 86:13-36 291:36-53
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:15-46
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:16-47
 @ ./node_modules/@shopify/shopify-api/dist/auth/session/storage/sqlite.js 5:40-58
 @ ./node_modules/@shopify/shopify-api/dist/context.js 7:15-55
 @ ./node_modules/@shopify/shopify-api/dist/index.js 5:16-36
 @ ./apps/client-app/src/services/shopify/shopify-webhook-api.service.ts 16:22-53
 @ ./apps/client-app/src/artifacts.module.ts 70:38-95
 @ ./apps/client-app/src/app.module.ts 19:27-56
 @ ./apps/client-app/src/main.ts 9:21-44

ERROR in ./node_modules/pg/lib/native/client.js 4:13-33
Module not found: Error: Can't resolve 'pg-native' in '/Users/shashank/Projects/cooee/node-backend-app/node_modules/pg/lib/native'
 @ ./node_modules/pg/lib/native/index.js 2:0-36
 @ ./node_modules/pg/lib/index.js 29:26-45 40:24-43
 @ ./node_modules/@shopify/shopify-api/dist/auth/session/storage/postgresql.js 5:35-48
 @ ./node_modules/@shopify/shopify-api/dist/auth/session/index.js 14:19-50
 @ ./node_modules/@shopify/shopify-api/dist/index.js 8:40-65
 @ ./apps/client-app/src/services/shopify/shopify-webhook-api.service.ts 16:22-53
 @ ./apps/client-app/src/artifacts.module.ts 70:38-95
 @ ./apps/client-app/src/app.module.ts 19:27-56
 @ ./apps/client-app/src/main.ts 9:21-44

4 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.72.1 compiled with 6 errors in 5971 ms

Tried a couple of solutions but didn't work.

Environment

System:

NodeJS : v16.13.1 npm : 8.1.2 OS : macOS

gaurav-pachar commented 2 years ago

installing the 'sqlite3' package before installing this 'shopify-node-api', worked for me.

TomZilys commented 2 years ago

Anyone found a solution? We have same problem with @shopify/shopify-api Installing sqlite3 didn't help

ryujimorimoto commented 2 years ago

全く同じ問題を抱えています。 lambdaにデプロイしたときに発生します。 @shopify/shopify-api を v4.0.0 に変更した後におきました。

{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module '/var/task/web/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-arm64/node_sqlite3.node'\nRequire stack:\n- /var/task/web/node_modules/sqlite3/lib/sqlite3-binding.js\n- /var/task/web/node_modules/sqlite3/lib/sqlite3.js",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module '/var/task/web/node_modules/sqlite3/lib/binding/napi-v6-linux-glibc-arm64/node_sqlite3.node'",
        "Require stack:",
        "- /var/task/web/node_modules/sqlite3/lib/sqlite3-binding.js",
        "- /var/task/web/node_modules/sqlite3/lib/sqlite3.js",
        "    at _loadUserApp (file:///var/runtime/index.mjs:726:17)",
        "    at async Object.module.exports.load (file:///var/runtime/index.mjs:741:21)",
        "    at async file:///var/runtime/index.mjs:781:15",
        "    at async file:///var/runtime/index.mjs:4:1"
    ]
}

I have the exact same problem. Occurs when deploying to lambda. It happened after changing @shopify/shopify-api to v4.0.0.

heartmon commented 2 years ago

I also just have same problem with sqlite in my docker container I got this first Error: Error relocating /node_modules/sqlite3/lib/binding/napi-v6-linux-musl-x64/node_sqlite3.node: _ZSt28__throw_bad_array_new_lengthv: symbol not found

and also this Cannot find module '/node_modules/sqlite3/lib/binding/napi-v6-linux-musl-x64/node_sqlite3.node'

ghost commented 2 years ago

Having the same problem deploying to AWS AppRunner.

For me a temporary fix was to fix the Shopify API to version 3.0.0 in my package.json:

"@shopify/shopify-api": "3.0.0"

Hope this helps anyone.

darius-gai commented 2 years ago

Looks related to #410

lukeclifton commented 2 years ago

Also getting the same issue.

I can run yarn install successfully up till v3.0.1 but updating to v3.1.0 breaks.

error /node_modules/sqlite3: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
weisslertal commented 2 years ago

I also get the same issue. Hope it's resolved soon

0xWhiteleaf commented 2 years ago

...

sagrawal31 commented 1 year ago

Any update here? This has become blocker for upgrade.

doneumark commented 1 year ago

same here :(

dotdev-barrick commented 1 year ago

I can't believe any library would use SQLite as a dependency...

lukeclifton commented 1 year ago

@BarrickH v6 which was released recently has now removed the session storage interfaces from the lib. https://github.com/Shopify/shopify-api-js/blob/main/docs/migrating-to-v6.md#changes-to-session-and-sessionstorage

bernier commented 1 year ago

@lukeclifton v6 didn't resolve the SQLite issue. See https://github.com/Shopify/shopify-api-js/issues/410

dotdev-barrick commented 1 year ago

@lukeclifton Thanks for the advice. Migrate to V6 and the shopify.auth.begin function for OAuth got totally broken in my app ; ) ...

[shopify-api/INFO] Beginning OAuth | {shop: stance.myshopify.com, isOnline: false, callbackPath: /app-auth/callback} [Nest] 66610 - 15/12/2022, 10:09:04 am ERROR [ExceptionsHandler] Missing adapter implementation for 'abstractConvertRequest' - make sure to import the appropriate adapter for your platform Error: Missing adapter implementation for 'abstractConvertRequest' - make sure to import the appropriate adapter for your platform at abstractConvertRequest (/Volumes/Development/backend_project/stance/dist/node_modules/@shopify/shopify-api/runtime/http/index.ts:34:9) at /Volumes/Development/backend_project/stance/dist/node_modules/@shopify/shopify-api/lib/auth/oauth/oauth.ts:57:49

ko-lem commented 1 year ago

@BarrickH Same. I had to run npm audit fix --force because of some jsonwebtoken issue. It updated shopify-api to v6 and now I'm in a rabbit hole of migration issues.

Edit: Our issue doesn't seem to be related to sqlite.

  1. https://github.com/Shopify/shopify-api-js/blob/16730c53b496ea9b575536e2c55f890aed58c882/lib/auth/oauth/oauth.ts#L57
  2. https://github.com/Shopify/shopify-api-js/blob/16730c53b496ea9b575536e2c55f890aed58c882/runtime/http/index.ts#L33

Edit 2: After digging through their source code, I figured out that we just need to do import '@shopify/shopify-api/adapters/node' before import ... from '@shopify/shopify-api'. Then saw that it was in this guide after all

paulomarg commented 1 year ago

Hi folks, sorry for the delay in responding to this issue. We've been listening to the points raised here and we fixed the issue with sqlite in v6+ by removing all storage options as dependencies.

We're still supporting the same options as before with the packages in https://github.com/Shopify/shopify-app-js, but you'll have to import them individually (or create your own) and call them when you need to store / load sessions.

As for the last issue pointed out, the fix is indeed to call this before calling shopifyApi

import '@shopify/shopify-api/adapters/node'

This is necessary because this library now works with any JS runtime (like Cloudflare workers, for example), so apps need to specify which runtime to load.

To prevent others coming in from having the same issue, I'll improve the guide to make this very important change more visible.

Since the original problem with sqlite no longer applies, I'll close this issue. Please do open new issues if you still have any problems.