MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
946 stars 277 forks source link

TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function #335

Closed thomasverleye closed 4 years ago

thomasverleye commented 4 years ago

When i'm trying a simple example I'm getting the following error log:

internal/util.js:214
    throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'original', 'function');
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function
    at Object.promisify (internal/util.js:214:11)
    at Object.<anonymous> (/Users/thomasverleye/Sites/personal/kerckstede/orders/node_modules/got/dist/source/get-response.js:8:25)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/thomasverleye/Sites/personal/kerckstede/orders/node_modules/got/dist/source/request-as-event-emitter.js:13:24)

Here's the source-code I've been trying to use:

const Shopify = require('shopify-api-node');

const shopify = new Shopify({
  shopName: 'REDACTED',
  apiKey: 'REDACTED',
  password: 'REDACTED'
});

shopify.order
  .list({ limit: 5 })
  .then((orders) => console.log(orders))
  .catch((err) => console.error(err));

My Setup: Node Version: v8.13.0 NPM Version: 6.4.1

jacintofleta commented 4 years ago

I'm having the exact same issue.

lpinca commented 4 years ago

Node.js 8 is no longer supported. shopify-api-node@3 requires Node.js >= 10.

thomasverleye commented 4 years ago

Alright cool, I will check this and confirm later on. Maybe it would be a good idea if we mention this in the readme.md? 🙇

lpinca commented 4 years ago

You should get a warning when installing on an unsupported Node.js version as per https://github.com/MONEI/Shopify-api-node/blob/3.0.0/package.json#L10

jacintofleta commented 4 years ago

I'm on Node v12.14.0 and having the same issue (with the same code).

lpinca commented 4 years ago

@jacinfleta I've tested the example in the issue description and it works fine on Node.js 10.18.1 and 13.6.0. Will check v12 later.

jacintofleta commented 4 years ago

@lpinca thank you so much. I'll continue investigating. I'm very newbie so I bet the problem is my own.

thomasverleye commented 4 years ago

I've updated node to v13.7.0 and it works flawless.

@jacinfleta I'd suggest you update your node as well, if you need v12 for other projects i'd suggest you use some version controller like nvm to switch between node versions.

Thanks again @lpinca I'm closing this issue now.

tomardern commented 4 years ago

Just ran into this issue myself - I was trying to deploy to Google Cloud Functions / Firebase.

Please can you add that node 10 is required in the readme?