Skip to content

Module not found in examples/local-state-sharing. #1736

@tarunama

Description

@tarunama

Bug report

~/p/o/local-state-sharing> yarn dev
yarn run v1.22.15
$ next
The module 'react' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install react'
The module 'react-dom' was not found. Next.js requires that you include it in 'dependencies' of your 'package.json'. To add it, run 'npm install react-dom'
internal/modules/cjs/loader.js:888
  throw err;
  ^

Error: Cannot find module 'react'
Require stack:
- /projects/oss/local-state-sharing/node_modules/next/dist/shared/lib/utils.js
- /Users//projects/oss/local-state-sharing/node_modules/next/dist/server/config.js
- /Users//projects/oss/local-state-sharing/node_modules/next/dist/server/next.js
- /Users//projects/oss/local-state-sharing/node_modules/next/dist/server/lib/start-server.js
- /Users//projects/oss/local-state-sharing/node_modules/next/dist/cli/next-dev.js
- /Users//projects/oss/local-state-sharing/node_modules/next/dist/bin/next
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
    at Function.Module._load (internal/modules/cjs/loader.js:730:27)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users//projects/oss/local-state-sharing/node_modules/next/dist/shared/lib/utils.js:15:14)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Module.require (internal/modules/cjs/loader.js:957:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/yamamototakuya/projects/oss/local-state-sharing/node_modules/next/dist/shared/lib/utils.js',
    '/Users/yamamototakuya/projects/oss/local-state-sharing/node_modules/next/dist/server/config.js',
    '/Users/yamamototakuya/projects/oss/local-state-sharing/node_modules/next/dist/server/next.js',
    '/Users/yamamototakuya/projects/oss/local-state-sharing/node_modules/next/dist/server/lib/start-server.js',
    '/Users/yamamototakuya/projects/oss/local-state-sharing/node_modules/next/dist/cli/next-dev.js',
    '/Users/yamamototakuya/projects/oss/local-state-sharing/node_modules/next/dist/bin/next'
  ]
}

Description / Observed Behavior

examples/local-state-sharing failed to execute yarn dev command.

Expected Behavior

examples/local-state-sharing execute yarn dev command.

To resolve this, add modules of react and react-dom ?

Repro Steps / Code Example

  1. curl https://codeload.github.com/vercel/swr/tar.gz/main | tar -xz --strip=2 swr-main/examples/local-state-sharing
  2. cd local-state-sharing
  3. yarn
  4. yarn dev

Additional Context

package.json

{
  "name": "local-state-sharing",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "next": "latest",
    "swr": "latest"
  },
  "scripts": {
    "dev": "next",
    "start": "next start",
    "build": "next build"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    exampleChanges related to examples

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions