rollup / rollup

Next-generation ES module bundler
https://rollupjs.org
Other
25.38k stars 1.53k forks source link

Cannot find module @rollup/rollup-win - nuxt 3 - npm install fail #5325

Closed JulienHenrotin closed 10 months ago

JulienHenrotin commented 10 months ago

Rollup Version

4.9.2

Operating System (or Browser)

Windows 11

Node Version (if applicable)

20.10.0

Link To Reproduction

https://github.com/JulienHenrotin/testNuxt3

Expected Behaviour

I can no longer launch my Nuxt 3 project due to Rollup package

I cloned my web project into a machine with a fresh Windows 11 installation but I'm unable to get past the package installation step.

Before this, I installed Node using NVM (Node Version Management).

After clone project I just have to install dependencies before run the project.

Environment


Actual Behaviour

When I run npm install, I get the following error:

[15:25:31]  ERROR  Cannot find module @rollup/rollup-win32-x64-msvc. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try npm i again after removing both package-lock.json and node_modules directory.

  at requireWithFriendlyError (node_modules\rollup\dist\native.js:87:9)
  at Object.<anonymous> (node_modules\rollup\dist\native.js:96:48)
  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 cjsLoader (node:internal/modules/esm/translators:345:17)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:294:7)
  at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
  at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)

[15:25:31]  ERROR  Cannot find module @rollup/rollup-win32-x64-msvc. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try npm i again after removing both package-lock.json and node_modules directory.

npm ERR! code 1
npm ERR! path C:\Users\julie\Downloads\my_project
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c nuxt prepare

What I tried:

TrickyPi commented 10 months ago

Could you try using 'npm i @rollup/rollup-win32-x64-msvc' to install this package?

JulienHenrotin commented 10 months ago

Could you try using 'npm i @rollup/rollup-win32-x64-msvc' to install this package?

Already try it but no apparent change.

anthonysanlucas commented 8 months ago

This issue is solved in a simple way, using pnpm. 😀

After several minutes trying to fix it I decided to use another package manager.

mahsarajabpour commented 6 months ago

I used the commands npm cache clean --force and rm -rf node_modules package-lock.json. Then I realized that I could prevent the same error from occurring without needing to add the optional rollup dependency. It was just necessary to remove the --no-optional flag in the "Install Dependencies" section of my ci.yml file. I hope that helps!

Moe03 commented 4 months ago

+1

Bhavanesh22 commented 2 months ago

necessary @mahsarajabpour

I am facing the above issues in angular. I am not getting your point. Can you please elaborate this.

DikshaAdhikari commented 1 month ago

@Bhavanesh22 did you find the solution for this? I am facing the same issue in angular and I have tried almost everything mentioned above

Bhavanesh22 commented 1 month ago

@Bhavanesh22 did you find the solution for this? I am facing the same issue in angular and I have tried almost everything mentioned abov

Bhavanesh22 commented 1 month ago

@DikshaAdhikari

This issue happens because of jfrog configuration and npm is not installing properly. I didn't find the permanent solution for this issue.

But I have a temporary solution.

Get a copy of nodemodules/@rollup file from any of your previous working project or get it from your colleague and replace the file in your current project.

Keep the working rollup file for future use .

DikshaAdhikari commented 1 month ago

Thank you @Bhavanesh22, it worked for me :)