skip to Main Content

I have installed Node.js Shopify CLI and using Homebrew.

When run shopify app dev it provides a local url http://localhost:56467/ . This url giving error below.

Unexpected identifier ‘assert’

at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:166:18)
at callTranslator (node:internal/modules/esm/loader:416:14)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:422:30

Click outside, press Esc key, or fix the code to dismiss.
You can also disable this overlay by setting server.hmr.overlay to false in vite.config.js.

I am using below version software

 node version = v22.0.0

 npm  version = 10.5.1

 Current Shopify CLI version = 3.59.1

 ruby version = ruby 2.6.10p210 (2022-04-12 revision 67958)
[universal.x86_64-darwin21]

 macOS Monterey version 12.7.4

enter image description here

2

Answers


  1. Your Current Shopify CLI version: 3.59.1 is latest and you are also using latest version of node.

    Downgrade your node version

    First check nvm is available or not in your system (nvm -v).

    if not available install nvpm

    Download nvm installation script

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
    

    Verify nvm installation

    nvm --version
    

    Check available version of node

    nvm ls
    

    Use nvm to install Node.js 20

    nvm install 20
    

    Use Node.js version 20

    nvm use 20
    

    Run shopify app dev and test your local url

    Login or Signup to reply.
  2. Various Shopify JavaScript packages released prior to the end of May 2024 weren’t compatible with Node v22, because they used the old import assertions syntax that was removed from Node in v22.

    This was fixed by commit https://github.com/Shopify/shopify-app-js/commit/b9e7bb60cd96eb67949239eae5380a4cbf3baa8a, on May 28th 2024. Any Shopify package release on npm since then should be compatible with Node v22 (but not with Node v16; support for Node v16 was dropped in order to support Node v22).

    So at this point, you should be able to fix this error by upgrading all your Shopify dependencies (perhaps including transitive ones) to the latest version.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search