unexpected identifier 'assert' error

Solved

unexpected identifier 'assert' error

Bizetools
Shopify Partner
2 0 0

Hi,
On creating a new app with Shopify CLI v 3.5.9, and after running npm update -g , I see an error in terminal:
18:35:20 │ remix │ 6:35:20 PM [vite] Internal server error: Unexpected identifier 'assert'
18:35:20 │ remix │ at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
18:35:20 │ remix │ at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:166:18)
18:35:20 │ remix │ at callTranslator (node:internal/modules/esm/loader:416:14)
18:35:20 │ remix │ at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:422:30)

Tried to then install on Shopify dev and get the following:
Screenshot 2024-05-03 at 6.45.04 PM.png

I have deleted and recreated, then reinstalled, each time deleting from the partner console. Can anyone share a solution, Thanks for any help

 

Accepted Solution (1)

oscprofessional
Shopify Partner
16116 2409 3125

This is an accepted solution.

HEllo @Bizetools ,

The error you're encountering, "Unexpected identifier 'assert'", is related to a compatibility issue between the @shopify/shopify-app-remix package version and your Node.js version. Here's how to address it:

Understanding the Issue:

  • The assert identifier is a built-in Node.js assertion function that might not be available in older Node.js versions.
  • The @shopify/shopify-app-remix package version you're using (likely above 2.8.1) might be introducing code that relies on this function.

Solution:

  1. Downgrade @shopify/shopify-app-remix:

    • In your project's package.json file, adjust the version of @shopify/shopify-app-remix to a compatible version. A confirmed working version is 2.8.0.
    • Run npm install or yarn install to install the downgraded package.

 

JSON

// package.json
"dependencies": {
  "@shopify/shopify-app-remix": "2.8.0"
}

 

  • Upgrade Node.js (if possible):
  • If feasible, consider upgrading your Node.js version to a more recent LTS (Long-Term Support) release. Newer Node.js versions typically have better compatibility with modern packages.
  • Check the documentation for @shopify/shopify-app-remix to see if there are specific Node.js version requirements.
    • Additional Tips:

      • After making changes, restart your development server to ensure the new package version or Node.js environment is reflected.
      • If you encounter further issues, refer to the Shopify app template repository or the @shopify/shopify-app-remix package documentation for troubleshooting guidance.

      By following these steps, you should be able to resolve the "Unexpected identifier 'assert'" error and proceed with developing your Shopify app using Remix.

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free

View solution in original post

Replies 2 (2)

oscprofessional
Shopify Partner
16116 2409 3125

This is an accepted solution.

HEllo @Bizetools ,

The error you're encountering, "Unexpected identifier 'assert'", is related to a compatibility issue between the @shopify/shopify-app-remix package version and your Node.js version. Here's how to address it:

Understanding the Issue:

  • The assert identifier is a built-in Node.js assertion function that might not be available in older Node.js versions.
  • The @shopify/shopify-app-remix package version you're using (likely above 2.8.1) might be introducing code that relies on this function.

Solution:

  1. Downgrade @shopify/shopify-app-remix:

    • In your project's package.json file, adjust the version of @shopify/shopify-app-remix to a compatible version. A confirmed working version is 2.8.0.
    • Run npm install or yarn install to install the downgraded package.

 

JSON

// package.json
"dependencies": {
  "@shopify/shopify-app-remix": "2.8.0"
}

 

  • Upgrade Node.js (if possible):
  • If feasible, consider upgrading your Node.js version to a more recent LTS (Long-Term Support) release. Newer Node.js versions typically have better compatibility with modern packages.
  • Check the documentation for @shopify/shopify-app-remix to see if there are specific Node.js version requirements.
    • Additional Tips:

      • After making changes, restart your development server to ensure the new package version or Node.js environment is reflected.
      • If you encounter further issues, refer to the Shopify app template repository or the @shopify/shopify-app-remix package documentation for troubleshooting guidance.

      By following these steps, you should be able to resolve the "Unexpected identifier 'assert'" error and proceed with developing your Shopify app using Remix.

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing | Oscp Upsell & Cross sell App : Free | Oscp Sales & Volume Discount App : Free | Custom Pricing Wholesale App : Free
Bizetools
Shopify Partner
2 0 0

Thank you!! The combination of setting node to v 20 (was on 20.12.2) and @Shopify/shopify-app-remix": "^2.8.2 enabled creation and installation with out the error. Really appreciate your help