epicweb-dev / react-fundamentals

Material for my React Fundamentals Workshop
https://fundamentals.epicreact.dev
Other
5.3k stars 3.21k forks source link

npm run setup issues #380

Closed infantito closed 2 months ago

infantito commented 2 months ago
MacOs - M1 Max - Sonoma OS

Node version: v20.17.0
npm version: 10.8.2
npx version: 10.8.2

I've cloned the project and I've ran npm run setup but it throws an error:

➜ npm run setup

> setup
> node ./epicshop/setup.js

▶️  Starting workshop setup...
      Running the following command: npx --yes "https://gist.github.com/kentcdodds/bb452ffe53a5caa3600197e1d8005733" -q
    ▶️  Starting: System Validation
          Ensuring the correct versions of tools are installed on this computer.
          Running the following command: npx --yes "https://gist.github.com/kentcdodds/abbc32701f78fa70298d444c2303b6d9"
    ✅  Success: System Validation

    ▶️  Starting: Dependency Installation
          Installing third party code dependencies so the workshop works properly on this computer.
          Running the following command: npm install --legacy-peer-deps --no-save

> postinstall
> cd ./epicshop && npm install

npm error code EEXIST
npm error syscall rename
npm error path /.npm/_cacache/tmp/36463a40
npm error dest /.npm/_cacache/content-v2/sha512/64/cd/fd06767db7fc59fe7178530447e629744b0f7742765777d3406464692208f4caf5703e92ddef4dacfc2c7de79ac668c97205091927622beeac98e3c559fa
npm error errno -13
npm error EACCES: permission denied, rename '/.npm/_cacache/tmp/36463a40' -> '/.npm/_cacache/content-v2/sha512/64/cd/fd06767db7fc59fe7178530447e629744b0f7742765777d3406464692208f4caf5703e92ddef4dacfc2c7de79ac668c97205091927622beeac98e3c559fa'
npm error File exists: /.npm/_cacache/content-v2/sha512/64/cd/fd06767db7fc59fe7178530447e629744b0f7742765777d3406464692208f4caf5703e92ddef4dacfc2c7de79ac668c97205091927622beeac98e3c559fa
npm error Remove the existing file and try again, or run npm
npm error with --force to overwrite files recklessly.
npm error A complete log of this run can be found in: /.npm/_logs/2024-09-27T16_28_42_628Z-debug-0.log
npm error code 243
npm error path /epic-react/react-fundamentals
npm error command failed
npm error command sh -c cd ./epicshop && npm install
npm error A complete log of this run can be found in: /.npm/_logs/2024-09-27T16_28_41_616Z-debug-0.log
    🚨  Failure: Dependency Installation. Please review the messages above for information on how to troubleshoot and resolve this issue.

Any idea about it?

kentcdodds commented 2 months ago

It looks like you're running into a permission issue with npm. Specifically, npm doesn't have the right permissions to access or rename certain files within its cache (_cacache). This kind of error usually happens when running commands as a non-root user without the necessary permissions.

Here are a couple of ways you could resolve this:

  1. Fixing permissions: Try adjusting the permissions of the .npm directory by running this command:

    sudo chown -R $(whoami) ~/.npm

    This will ensure that the current user has ownership of the .npm folder and its contents.

  2. Using sudo: If the permissions adjustment doesn't work, try running the setup script using sudo:

    sudo npm run setup
  3. Cleaning the cache: Sometimes the issue is with a corrupt npm cache. Try clearing the cache with:

    npm cache clean --force

    Then, retry the setup:

    npm run setup

Give these a try and let me know if the issue persists!

Option 3 is probably safest. If you have to run npm commands with sudo then you're in trouble.

infantito commented 2 months ago

Thanks @kentcdodds , that solved my problem.