designsystemsinternational / mechanic

Mechanic is a framework to build assets built on web code.
https://mechanic.design
MIT License
253 stars 11 forks source link

Module 'immer' cannot be resolved #123

Closed lucasdinonolte closed 2 years ago

lucasdinonolte commented 2 years ago

Describe the bug After generating a React-Image project from the CLI and starting the dev server, loading the page in the browser fails with an error on the command line:

ERROR in ./node_modules/use-immer/dist/use-immer.module.js 1:0-34
Module not found: Error: Can't resolve 'immer' in '~/projects/project-name/node_modules/use-immer/dist'

To Reproduce Steps to reproduce the behavior:

  1. Generate a project using npm init mechanic@latest
  2. I chose the React Image template – haven't checked for other templates
  3. Choose to install the dependencies – for me it used yarn
  4. Start the dev server
  5. Open localhost:3000 and find the error on the command line

Expected behavior The dev server should start normally, with all dependencies being in place.

Desktop (please complete the following information):

Additional context Manually installing immer as a dependency solves the issue.

fdoflorenzano commented 2 years ago

This is weird! I can't reproduce the bug, I don't get the error with a new project. @bravomartin @runemadsen can either of you try it?

lucasdinonolte commented 2 years ago

Had a look at it again. Maybe this helps to narrow the issue down. I figured that skipping installation in the CLI and running npm install myself avoids the issue. The CLI would use yarn to install for me.

I've also tried this using multiple node versions which makes the issue even weirder:

npm list -g does not include immer for any of the versions. Maybe this is also an issue with my node setup. I'll try on a different machine later and update the details accordingly.

fdoflorenzano commented 2 years ago

I think it may be a peer dependency issue. I believe yarn and different npm versions handle peer dependencies differently, and the issue here is that even tho use-immer is declared as a dependency, immer is not. I'll do a little release with this change. (I'll also include your latest PR)

fdoflorenzano commented 2 years ago

I published a new release! v2.0.0-beta.4. Whenever you can, try the same order with npm init mechanic@latest, let's hope this time it works! 🤞🏽

lucasdinonolte commented 2 years ago

Yes, this solves it 😊

fdoflorenzano commented 2 years ago

Amazing 🎉