Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build project on windows [ERR_MODULE_NOT_FOUND] #8463

Closed
1 of 3 tasks
Tfines19 opened this issue Apr 26, 2024 · 1 comment
Closed
1 of 3 tasks

Unable to build project on windows [ERR_MODULE_NOT_FOUND] #8463

Tfines19 opened this issue Apr 26, 2024 · 1 comment

Comments

@Tfines19
Copy link

Description

When I go to build the projects files with pnpm dev or pnpm build I run into this error.
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\tfine\OneDrive\Documents\projects\chakra-ui\packages\utils\C:\Users\tfine\OneDrive\Documents\projects\chakra-ui\packages\utils\package.json' imported from C:\Users\tfine\OneDrive\Documents\projects\chakra-ui\scripts\build\main.ts

For some reason the path is doubling up and causing the build to crash. In scripts/build/main.ts the code causing the error appears to be

const cwd = process.cwd();
const packageJson = await import(resolve(cwd, "package.json"))

I just dont know why resolve would be causing the issue. cwd for me shows up as a normal path but it gets wonky when put into resolve. Running latest version of node on windows 11.

Link to Reproduction

https://codesandbox.io

Steps to reproduce

  1. Fork and clone chakra-ui main branch
  2. Run pnpm install
  3. Run pnpm dev OR pnpm build

Chakra UI Version

2.0.0

Browser

No response

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

No response

@Tfines19
Copy link
Author

Tfines19 commented Apr 30, 2024

It appears there is a couple of issues building the project on windows. There is a resolve function imported from node:path/posix that is messing up the path for windows. Switching that to node:path instead fixed that but caused another error. It seems there is an issue using await import() on a package.json so I had to switch to using const packageJson = JSON.parse( await readFile(resolve(process.cwd(), "package.json"), "utf-8"), )to load the package json and also had to change the resolve to join in getBasePath. Since making those changes I can now build the project.

@Tfines19 Tfines19 changed the title Unable to build project [ERR_MODULE_NOT_FOUND] Unable to build project on windows [ERR_MODULE_NOT_FOUND] Apr 30, 2024
@Tfines19 Tfines19 closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant