Solved

Getting error trying to install latest versions of React and Polaris

ElevateMyStore
Tourist
4 1 1

I am just getting into Shopify app development with React and Polaris and even before I write a single line of code I am confronted with this error when trying to simply install the latest version of React + Polaris.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: sample_app@1.0.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.9.0" from @Shopify/polaris@6.0.1
npm ERR! node_modules/@shopify/polaris
npm ERR!   @Shopify/polaris@"*" from the root project

 

Is anyone else getting this error? Is the only solution to install an older version of React?

Accepted Solution (1)

ElevateMyStore
Tourist
4 1 1

This is an accepted solution.

**Update**

Normally I am used to installing the primary libraries first like React but in this instance installing @Shopify/polaris first and letting npm figure out the necessary versions for React and React-dom worked like a charm.

FIX: Install @Shopify/polaris first then react, react-dom, next libraries.

"@shopify/koa-shopify-auth": "^3.2.0",
    "@shopify/polaris": "^6.0.1",
    "dotenv": "^8.2.0",
    "isomorphic-fetch": "^3.0.0",
    "koa": "^2.13.1",
    "koa-session": "^6.1.0",
    "next": "^10.0.7",
    "react": "^16.14.0",
    "react-dom": "^16.14.0"

 

View solution in original post

Replies 2 (2)

ElevateMyStore
Tourist
4 1 1

This is an accepted solution.

**Update**

Normally I am used to installing the primary libraries first like React but in this instance installing @Shopify/polaris first and letting npm figure out the necessary versions for React and React-dom worked like a charm.

FIX: Install @Shopify/polaris first then react, react-dom, next libraries.

"@shopify/koa-shopify-auth": "^3.2.0",
    "@shopify/polaris": "^6.0.1",
    "dotenv": "^8.2.0",
    "isomorphic-fetch": "^3.0.0",
    "koa": "^2.13.1",
    "koa-session": "^6.1.0",
    "next": "^10.0.7",
    "react": "^16.14.0",
    "react-dom": "^16.14.0"

 

Mustavanov
Visitor
2 0 1

I'm trying to create a sample app using this article provided by Shopify from Shopify Build App Tutorial

but when I reached the point to install Polaris I faced this problem in my vs.code 

when I run:

npm install --save @shopify/polaris webpack@4

 

I get this error:

 

 

 

 

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: simple-shopify-app@1.0.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.9.0" from /polaris@6.5.0
npm ERR! node_modules/@shopify/polaris
npm ERR!   /polaris@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\iSmail\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\iSmail\AppData\Local\npm-cache\_logs\2021-06-16T21_55_34_554Z-debug.log

 

 

 

 

 

and this is my "package.json" file code: 

 

 

 

 

{
  "name": "simple-shopify-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "node server.js",
    "build": "next build",
    "start": "NODE_ENV=production node server.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@shopify/koa-shopify-auth": "^4.1.3",
    "@shopify/koa-shopify-graphql-proxy": "^5.0.0",
    "@shopify/shopify-api": "^1.4.1",
    "dotenv": "^10.0.0",
    "isomorphic-fetch": "^3.0.0",
    "koa": "^2.13.1",
    "koa-router": "^8.0.8",
    "koa-session": "^6.2.0",
    "next": "^11.0.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}

 

 

 

 

 

 

Please help me fix this and install Polaris on my project correctly!

Thank You!