Module not found: can't resolve 'moralis -v1'

When trying to start my react app, I keep getting this error message “Module not found: can’t resolve ‘moralis -v1’”, please I need help

1 Like

Here’s the error message

you could try to install moralis with an older version, what dependencies are you using now?

Thanks for replying, it’s “moralis”: “^1.11.0”

where from is moralis-v1 then? you try to import moralis-v1?

Not at all, that’s why I still don’t understand the error…

maybe you have a newer version of react moralis that tries to use moralis-v1
you could try to add moralis-v1 in the dependencies or to downgrade react moralis

Please how can I add moralis-v1 in the dependencies?

you could try to install it, how did you add moralis in first place?

1 Like


Pleqse I keep getting this error message whenever I try running “npm run dev”

Can you post your package.json file. Are you using fs anywhere, or what changes in code have you made?

{

  "name": "ryc",

  "version": "0.1.0",

  "homepage": "https://gifting.com",

  "private": true,

  "scripts": {

    "dev": "node server.js",

    "build": "next build",

    "start": "NODE_ENV=production node server.js"

  },

  "dependencies": {

    "@chakra-ui/react": "^1.8.8",

    "@emotion/react": "^11.9.0",

    "@emotion/styled": "^11.8.1",

    "@newrelic/next": "^0.3.0",

    "@next/swc-win32-x64-msvc": "^12.1.6",

    "@walletconnect/web3-provider": "^1.7.8",

    "@web3auth/web3auth": "^0.10.0",

    "browserify": "^17.0.0",

    "cleanup-react-app": "^1.1.3",

    "framer-motion": "^6.3.3",

    "git": "^0.1.5",

    "magic-sdk": "^8.1.1",

    "moralis": "^1.11.0",

    "moralis-v1": "^1.11.0",

    "next": "^12.3.1-canary.0",

    "react": "^18.1.0",

    "react-dom": "^18.1.0",

    "react-moralis": "^1.3.5",

    "react-responsive": "^9.0.0-beta.8",

    "react-scripts": "^4.0.1",

    "react-spring": "^9.0.0-rc.3",

    "styled-components": "^5.3.5",

    "web3": "^1.7.3",

    "webpack": "^5.74.0"

  },

  "devDependencies": {

    "eslint": "8.15.0",

    "eslint-config-next": "12.1.6"

  },

  "browser": {

    "fs": false,

    "path": false,

    "os": false

  }

}

What about the server.js file? Are you following a tutorial?

You have installed frontend libraries like chakra-ui but you seem to only be working with a Node.js script.

const { createServer } = require('http')

const { parse } = require('url')

const next = require('next')

const dev = process.env.NODE_ENV !== 'production'

const hostname = 'localhost'

const port = process.env.PORT || 3000

// when using middleware `hostname` and `port` must be provided below

const app = next({ dev, hostname, port })

const handle = app.getRequestHandler()

app.prepare().then(() => {

  createServer(async (req, res) => {

    try {

      // Be sure to pass `true` as the second argument to `url.parse`.

      // This tells it to parse the query portion of the URL.

      const parsedUrl = parse(req.url, true)

      const { pathname, query } = parsedUrl

      if (pathname === '/a') {

        await app.render(req, res, '/a', query)

      } else if (pathname === '/b') {

        await app.render(req, res, '/b', query)

      } else {

        await handle(req, res, parsedUrl)

      }

    } catch (err) {

      console.error('Error occurred handling', req.url, err)

      res.statusCode = 500

      res.end('internal server error')

    }

  }).listen(port, (err) => {

    if (err) throw err

    console.log(`> Ready on http://${hostname}:${port}`)

  })

})

please here is my server.js file

no im not following a tutorial

please i need help on this

Check out this thread, maybe something useful in there.

hi there :slight_smile:
in that case try to close your dev and open it again in your terminal with $npm/yarn dev. this worked with me

I am having the same issue, none of the above works

you are using react?