oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.53k stars 2.79k forks source link

Cannot find module on windows bun #10806

Open cacacaio opened 7 months ago

cacacaio commented 7 months ago

What version of Bun is running?

1.1.7+b0b7db5c0

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

I just went into a expo project and used bun install and then went ahead and bun start to run the expo start script on package.json and it gave me this error.

What is the expected behavior?

The project ran as normal.

What do you see instead?

Error: Cannot find module 'ajv/dist/compile/codegen'
Require stack:
- C:\Users\REDACTED\node_modules\ajv-keywords\dist\definitions\typeof.js
- C:\Users\REDACTED\node_modules\ajv-keywords\dist\keywords\typeof.js
- C:\Users\REDACTED\node_modules\ajv-keywords\dist\keywords\index.js
- C:\Users\REDACTED\node_modules\ajv-keywords\dist\index.js
- C:\Users\REDACTED\node_modules\schema-utils\dist\validate.js
- C:\Users\REDACTED\node_modules\schema-utils\dist\index.js
- C:\Users\REDACTED\node_modules\expo-router\plugin\build\index.js
- C:\Users\REDACTED\node_modules\expo-router\app.plugin.js
- C:\Users\REDACTED\node_modules\@expo\config-plugins\build\utils\plugin-resolver.js
- C:\Users\REDACTED\node_modules\@expo\config-plugins\build\plugins\withStaticPlugin.js
- C:\Users\REDACTED\node_modules\@expo\config-plugins\build\plugins\withPlugins.js
- C:\Users\REDACTED\node_modules\@expo\config-plugins\build\index.js
- C:\Users\REDACTED\node_modules\@expo\config\build\plugins\withConfigPlugins.js
- C:\Users\REDACTED\node_modules\@expo\config\build\Config.js
- C:\Users\REDACTED\node_modules\@expo\config\build\index.js
- C:\Users\REDACTED\node_modules\@expo\cli\build\src\utils\analytics\getDevClientProperties.js
- C:\Users\REDACTED\node_modules\@expo\cli\build\src\start\resolveOptions.js
- C:\Users\REDACTED\node_modules\@expo\cli\build\src\start\index.js
- C:\Users\REDACTED\node_modules\@expo\cli\build\bin\cli
- C:\Users\REDACTED\node_modules\expo\bin\cli
Error: Cannot find module 'ajv/dist/compile/codegen'
Require stack:
- C:\Users\REDACTED\node_modules\ajv-keywords\dist\definitions\typeof.js
- C:\Users\REDACTED\node_modules\ajv-keywords\dist\keywords\typeof.js
- C:\Users\REDACTED\node_modules\ajv-keywords\dist\keywords\index.js
- C:\Users\REDACTED\node_modules\ajv-keywords\dist\index.js
- C:\Users\REDACTED\node_modules\schema-utils\dist\validate.js
- C:\Users\REDACTED\node_modules\schema-utils\dist\index.js
- C:\Users\REDACTED\node_modules\expo-router\plugin\build\index.js
- C:\Users\REDACTED\node_modules\expo-router\app.plugin.js
- C:\Users\REDACTED\node_modules\@expo\config-plugins\build\utils\plugin-resolver.js
- C:\Users\REDACTED\node_modules\@expo\config-plugins\build\plugins\withStaticPlugin.js
- C:\Users\REDACTED\node_modules\@expo\config-plugins\build\plugins\withPlugins.js
- C:\Users\REDACTED\node_modules\@expo\config-plugins\build\index.js
- C:\Users\REDACTED\node_modules\@expo\config\build\plugins\withConfigPlugins.js
- C:\Users\REDACTED\node_modules\@expo\config\build\Config.js
- C:\Users\REDACTED\node_modules\@expo\config\build\index.js
- C:\Users\REDACTED\node_modules\@expo\cli\build\src\utils\analytics\getDevClientProperties.js
- C:\Users\REDACTED\node_modules\@expo\cli\build\src\start\resolveOptions.js
- C:\Users\REDACTED\node_modules\@expo\cli\build\src\start\index.js
- C:\Users\REDACTED\node_modules\@expo\cli\build\bin\cli
- C:\Users\REDACTED\node_modules\expo\bin\cli
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (C:\Users\REDACTED\node_modules\ajv-keywords\dist\definitions\typeof.js:3:19)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
error: script "start" exited with code 1

Additional information

I tried running bun create expo app-name and it works as normal so I don't know what's causing that in the app in question since it isn't everything out of the ordinary. These are the libs i'm running

{
  "name": "redacted",
  "version": "1.0.0",
  "main": "expo-router/entry",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
  },
  "dependencies": {
    "@expo/vector-icons": "^14.0.0",
    "@gorhom/bottom-sheet": "4",
    "@hookform/resolvers": "^2.9.8",
    "@tanstack/react-query": "^4.35.3",
    "axios": "0.24.0",
    "date-fns": "^2.29.3",
    "expo": "^50.0.0",
    "expo-checkbox": "~2.7.0",
    "expo-constants": "~15.4.5",
    "expo-font": "~11.10.3",
    "expo-image": "~1.10.6",
    "expo-image-picker": "~14.7.1",
    "expo-linear-gradient": "~12.7.2",
    "expo-linking": "~6.2.2",
    "expo-router": "~3.4.8",
    "expo-secure-store": "~12.8.1",
    "expo-status-bar": "~1.11.1",
    "expo-updates": "~0.24.11",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-hook-form": "^7.43.9",
    "react-native": "0.73.4",
    "react-native-dropdown-picker": "^5.4.4",
    "react-native-gesture-handler": "~2.14.0",
    "react-native-masked-text": "^1.13.0",
    "react-native-modal": "^13.0.1",
    "react-native-reanimated": "~3.6.2",
    "react-native-safe-area-context": "4.8.2",
    "react-native-screens": "~3.29.0",
    "react-native-svg": "14.1.0",
    "react-native-toast-message": "^2.1.5",
    "react-native-web": "~0.19.6",
    "styled-components": "^5.3.5",
    "yup": "^0.32.11"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/react": "~18.2.45",
    "@types/styled-components-react-native": "^5.1.3",
    "@typescript-eslint/eslint-plugin": "^5.32.0",
    "@typescript-eslint/parser": "^5.32.0",
    "babel-plugin-module-resolver": "^4.1.0",
    "eslint": "^8.21.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-prettier": "^8.5.0",
    "eslint-import-resolver-typescript": "^3.4.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jsx-a11y": "^6.6.1",
    "eslint-plugin-prefer-arrow-functions": "^3.1.4",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-react": "^7.30.1",
    "eslint-plugin-react-hooks": "^4.6.0",
    "prettier": "^2.7.1",
    "react-native-svg-transformer": "^1.0.0",
    "typescript": "^5.3.0"
  },
  "private": true
}
tianhuil commented 5 months ago

Try bun install -d ajv per https://github.com/expo/expo/issues/26641

I encountered the same issue with storybook. To reproduce:

$ git clone git@github.com:mantinedev/next-app-template.git
$ cd next-app-template
$ bun i
$ bun storybook

> mantine-next-template@1.0.0 storybook
> storybook dev -p 6006

@storybook/cli v8.1.10

info => Starting manager..
info => Starting preview..
info Addon-docs: using MDX3
info => Using implicit CSS loaders
=> Failed to build the preview
Error: Cannot find module 'ajv/dist/compile/codegen'
Require stack:
- ./node_modules/ajv-keywords/dist/definitions/typeof.js
- ./node_modules/ajv-keywords/dist/keywords/typeof.js
- ./node_modules/ajv-keywords/dist/keywords/index.js
- ./node_modules/ajv-keywords/dist/index.js
- ./node_modules/schema-utils/dist/validate.js
- ./node_modules/schema-utils/dist/index.js
- ./node_modules/webpack-dev-middleware/dist/index.js
- ./node_modules/@storybook/builder-webpack5/dist/index.js
- ./node_modules/@storybook/nextjs/dist/preset.js
- ./node_modules/@storybook/core-common/dist/index.js
- ./node_modules/@storybook/telemetry/dist/index.js
- ./node_modules/@storybook/cli/dist/generate.js
- ./node_modules/@storybook/cli/bin/index.js
- ./node_modules/storybook/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._resolveFilename (./node_modules/esbuild-register/dist/node.js:4799:36)
    at <anonymous> (./node_modules/next/src/server/require-hook.ts:51:34)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at Module.mod.require (./node_modules/next/src/server/require-hook.ts:70:26)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (./node_modules/ajv-keywords/src/definitions/typeof.ts:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

I hope @Jarred-Sumner , @dylan-conway , @paperdave , @Electroid, or one of the other maintainers can solve it soon!

dylan-conway commented 5 months ago

@tianhuil what version of bun are you using? This should've been fixed with #11473