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
2
Answers
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
Verify nvm installation
Check available version of node
Use nvm to install Node.js 20
Use Node.js version 20
Run
shopify app dev
and test your local urlVarious 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.