All things Shopify and commerce
Hello everyone,
I'm currently working on integrating the Shopify API into a Node.js project using ES Modules, and I've encountered a recurring issue with importing the library. Despite following the official documentation, I keep receiving errors related to importing named exports from '@shopify/shopify-api'.
Here’s the error I'm seeing when I try to run my application:
SyntaxError: The requested module '@shopify/shopify-api' does not provide an export named 'Shopify'
And after trying a different import approach, I received this:
Error: Missing adapter implementation for 'abstractRuntimeString' - make sure to import the appropriate adapter for your platform
Here is a snippet of my current setup:
import { Shopify, ApiVersion } from '@shopify/shopify-api';
Shopify.Context.initialize({
API_KEY: '[Your API Key]',
API_SECRET_KEY: '[Your API Secret]',
SCOPES: ['read_products', 'write_products', 'read_customers', 'write_customers', 'read_metafields', 'write_metafields'],
HOST_NAME: '[Your ngrok URL]',
IS_EMBEDDED_APP: false,
API_VERSION: ApiVersion.October21 // or the latest version
});
I'm using Node.js version 20.17.0 and the Shopify API library version is 11.4.1. Has anyone else faced this issue or can suggest what might be going wrong here? Any insights on whether there’s a change in how the library handles imports or if I’m missing an adapter for Node.js?
Any help or pointers towards what might be causing this and how to resolve it would be greatly appreciated!
Hello,The issue you're facing seems to stem from a couple of different factors. Let me address each one separately:
Named Exports Error:
The error SyntaxError: The requested module '@shopifyshopify-api' does not provide an export named 'Shopify' suggests that the version of the @shopifyshopify-api package you're using might not have the named export Shopify. In the latest versions of the Shopify API library, the module system has evolved, and the import syntax can differ depending on the type of module used in your project.
If you're using ES Modules, you may need to change your import to match what’s supported by the package. Try using this import statement:
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024