What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: npm create @shopify/hydrogen throw [ERROR Cannot read properties of null (reading 'useState')]

npm create @shopify/hydrogen throw [ERROR Cannot read properties of null (reading 'useState')]

HeisUser
Shopify Partner
2 0 6

Upon installing with npm create @Shopify/hydrogen or npm create @Shopify/hydrogen@latest

 

System keeps throw the Errors as below:

ERROR Cannot read properties of null (reading 'useState')

~/.npm/_npx/c78eec8d27f8df64/node_modules/@shopify/cli-kit/node_modules/react/cjs/react.development.js:1622:21

1619: }
1620: function useState(initialState) {
1621: var dispatcher = resolveDispatcher();
1622: return dispatcher.useState(initialState);
1623: }
1624: function useReducer(reducer, initialArg, init) {
1625: var dispatcher = resolveDispatcher();

- useState (~/.npm/_npx/c78eec8d27f8df64/node_modules/@shopify/cli-kit/node_modules/react/cjs/react.development.js:1622:21)
- usePrompt (file:///~/.npm/_npx/c78eec8d27f8df64/node_modules/@shopify/cli-kit/dist/private/node/ui/hooks/use-prompt.js:11:43)
- SelectPrompt (file:///~/.npm/_npx/c78eec8d27f8df64/node_modules/@shopify/cli-kit/dist/private/node/ui/components/SelectPrompt.js:12:64)
- renderWithHooks (~/.npm/_npx/c78eec8d27f8df64/node_modules/react-reconciler/cjs/react-reconciler.development.js:6659:18)
- mountIndeterminateComponent (~/.npm/_npx/c78eec8d27f8df64/node_modules/react-reconciler/cjs/react-reconciler.development.js:11276:13)
- beginWork (~/.npm/_npx/c78eec8d27f8df64/node_modules/react-reconciler/cjs/react-reconciler.development.js:12799:16)
- beginWork$1 (~/.npm/_npx/c78eec8d27f8df64/node_modules/react-reconciler/cjs/react-reconciler.development.js:19608:14)
- performUnitOfWork (~/.npm/_npx/c78eec8d27f8df64/node_modules/react-reconciler/cjs/react-reconciler.development.js:18742:12)
- workLoopSync (~/.npm/_npx/c78eec8d27f8df64/node_modules/react-reconciler/cjs/react-reconciler.development.js:18648:5)
- renderRootSync (~/.npm/_npx/c78eec8d27f8df64/node_modules/react-reconciler/cjs/react-reconciler.development.js:18616:7)

Replies 16 (16)

tim_tam
Visitor
1 0 1

I'm having the same issue.

RuhulSinbad
Shopify Partner
1 0 0

I am also facing the same issue

vguirou
Visitor
1 0 0

Same problem here

lionandlamb
Visitor
2 0 0

same here, any solution yet?

kalos_script11
Visitor
1 0 0

Same problem here XD

rewuxiin
Shopify Partner
3 1 0

same problem

Alexander_K
Shopify Partner
2 0 0

the same issue

victor_mendozaa
Visitor
1 0 0

I'm having the same issue, shopify can fix this pls?

Elliot016
Tourist
4 0 1

Im also getting this error. So has anyone found out why?

 

johnny2smooth
Shopify Partner
2 1 2

samesies

Nakules
Shopify Partner
2 0 0

Facing similar issue. Any fix available? 

ddiehlpdx
Shopify Partner
7 1 5

Facing the same error with a fresh install of the remix app template.

ddiehlpdx
Shopify Partner
7 1 5

I was able to resolve this for myself yesterday, after much trial and error. What worked for me was manually updating my package.json file to use the latest versions of the following packages. These are the latest versions as of this writing:

"@shopify/app": "3.58.2",
"@shopify/app-bridge-react": "^4.1.3",
"@shopify/cli": "3.59.2",

"@shopify/shopify-api": "^10.0.0",
"@shopify/shopify-app-remix": "^2.8.2",
"@shopify/shopify-app-session-storage-prisma": "^4.0.5"

 

After setting those versions in package.json, delete your node_modules folder(s) and your package-lock file, then run npm install again. After this npm run dev command started working for me again.

Tobidev
Shopify Partner
4 0 0

Yeah, this worked for me. How did you figure out that updating the packages was the issue? 

Id usually thinks the latest ones are more unstable.

ddiehlpdx
Shopify Partner
7 1 5

A lot of trial and error and researching the specific error codes and related dependencies. It wasn't a fun journey.

vadym_unify
Shopify Partner
1 0 0

Thanks a lot @ddiehlpdx you saved my day. I had the same issue, but it was related to running an existing app with the POS UI extension inside. Irritating react hook related issues nearly drove me crazy.
I tried upgrading CLI but didn't account for the other @shopify/... packages. THANKS!