Title: TypeError: WooCommerceRestApi is not a constructor
Last modified: June 9, 2020

---

# TypeError: WooCommerceRestApi is not a constructor

 *  Resolved [yonish3](https://wordpress.org/support/users/yonish3/)
 * (@yonish3)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/typeerror-woocommercerestapi-is-not-a-constructor-2/)
 * I was using NPM [@woocommerce/woocommerce-rest-api](https://www.npmjs.com/package/@woocommerce/woocommerce-rest-api)
   successfully to manage API requests to Woocommerce/ WP website.
 * Was using babel and CJS version:
 *     ```
       const WooCommerceRestApi = require("@woocommerce/woocommerce-rest-api").default;
   
       const api = new WooCommerceRestApi({
         url: "http://example.com",
         consumerKey: "ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
         consumerSecret: "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
         version: "wc/v3"
       });
       ```
   
 * But since Node 14 is offering a simple way to use ESM I have added the following
   configuration to the package.json, so I can use the import statement:` “type”:“
   module”
 * So I should have been able to use this format:
 *     ```
       import WooCommerceRestApi from "@woocommerce/woocommerce-rest-api";
   
       const api = new WooCommerceRestApi({
         url: "http://example.com",
         consumerKey: "ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
         consumerSecret: "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
         version: "wc/v3"
       });
       ```
   
 * But now I get this error:
 *     ```
       file:///xxxxxx/test.js:5
       const api = new WooCommerceRestApi({
                   ^
   
       TypeError: WooCommerceRestApi is not a constructor
           at file:///xxxxxxxx/test.js:5:13
           at ModuleJob.run (internal/modules/esm/module_job.js:138:23)
           at async Loader.import (internal/modules/esm/loader.js:178:24)
       ```
   
 * Why would that happen?
    -  This topic was modified 5 years, 11 months ago by [yonish3](https://wordpress.org/support/users/yonish3/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Phil](https://wordpress.org/support/users/fullysupportedphil/)
 * (@fullysupportedphil)
 * Automattic Happiness Engineer
 * [5 years, 11 months ago](https://wordpress.org/support/topic/typeerror-woocommercerestapi-is-not-a-constructor-2/#post-12973517)
 * Hey [@yonish3](https://wordpress.org/support/users/yonish3/),
 * These forums are intended for basic support of the default WooCommerce functionality.
   Not development and custom coding.
 * As such, you’ll likely get more replies by posting in either the [WooCommerce Advanced Facebook](https://www.facebook.com/groups/advanced.woocommerce/)
   group, or the [WooCommerce Developer Slack](https://woocommerce.com/community-slack/).
 *  [AJ a11n](https://wordpress.org/support/users/amandasjackson/)
 * (@amandasjackson)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/typeerror-woocommercerestapi-is-not-a-constructor-2/#post-12994266)
 * We haven’t heard back from you in a while, so I’m going to mark this as resolved–
   if you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘TypeError: WooCommerceRestApi is not a constructor’ is closed to new 
replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [AJ a11n](https://wordpress.org/support/users/amandasjackson/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/typeerror-woocommercerestapi-is-not-a-constructor-2/#post-12994266)
 * Status: resolved