kentcdodds / onewheel-blog

109 stars 27 forks source link

When executing "npm run dev" there will be an error message. #5

Closed cxc421 closed 2 years ago

cxc421 commented 2 years ago

Hi, I followed the steps below based on your course on egghead.

  1. npx create-remix --template remix-run/indie-stack onewheel-blog
  2. cd onewheel-blog
  3. npm run dev

Then the following error message appears.

image

Node version: 16.17.0 npm version: 8.15.0 platform: Ubuntu-22.04

Ngorror commented 2 years ago

Explanation of the problem (or at least my understanding of it)

In package.json file, devDependencies package msw version ^0.39.2 is used It will install at least msw version 0.45.0 on your computer and then you will receive as sub dependency newer headers-polyfill version 3.1.0 instead of 3.0.4 here is the diff that causes the problem: https://github.com/mswjs/headers-polyfill/compare/v3.0.4...v3.1.0#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R8 a new declaration of exports will break your npm installation

  "exports": {
    ".": {
      "types": "./lib/index.d.ts",
      "require": "./lib/index.js",
      "default": "./lib/esm/index.js"
    }
  }

Solution

just delete package-lock.json and update manually msw to version 0.47.3 and reinstall all other packages

rm -f -R node_modules
rm -f package-lock.json
npm install msw@0.47.3
npm install 

and voila! npm run dev is working :) you will have the right headers-polyfill version via the updated msw package and new and well tree-shaked package-lock.json

I'm trying to push a "Pull request" but it will be my first attempt in my dev life and it will take some time

Happy codding :)

kentcdodds commented 2 years ago

Thanks for the PR!