Cannot find module @rollup/rollup-win32-x64-msvc

方法1

在package.json中添加postinstall:

shell 复制代码
"scripts": {
    "postinstall": "node -e \"const { platform } = process; if (platform === 'win32') {  require('child_process').execSync('npm install @rollup/rollup-win32-x64-msvc', { stdio: 'inherit' }); } else if (platform === 'linux') { require('child_process').execSync('npm install @rollup/rollup-linux-x64-musl', { stdio: 'inherit' }); } else if (platform === 'darwin') {require('child_process').execSync('npm install @rollup/rollup-darwin-x64', { stdio: 'inherit' }); } else { console.log('Unsupported platform:', platform); }\""
  },

方法2

在package.json中添加optionalDependencies:

json 复制代码
"optionalDependencies": {
    "@rollup/rollup-win32-x64-msvc": "4.36.0",
    "@rollup/rollup-win32-arm64-msvc": "4.36.0",
    "@rollup/rollup-win32-ia32-msvc": "4.36.0",

    "@rollup/rollup-darwin-x64": "4.36.0",
    "@rollup/rollup-darwin-arm64": "4.36.0",

    "@rollup/rollup-linux-x64-gnu": "4.36.0",
    "@rollup/rollup-linux-x64-musl": "4.36.0",
    "@rollup/rollup-linux-arm-gnueabihf": "4.36.0",
    "@rollup/rollup-linux-arm-musleabihf": "4.36.0",
    "@rollup/rollup-linux-arm64-gnu": "4.36.0",
    "@rollup/rollup-linux-arm64-musl": "4.36.0",
    "@rollup/rollup-linux-loongarch64-gnu": "4.36.0",
    "@rollup/rollup-linux-powerpc64le-gnu": "4.36.0",
    "@rollup/rollup-linux-riscv64-gnu": "4.36.0",
    "@rollup/rollup-linux-s390x-gnu": "4.36.0"
  },

方法3

在package-lock.json中添加对应的包和版本:

json 复制代码
"node_modules/@rollup/rollup-darwin-arm64": {
      "version": "4.36.0",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.36.0.tgz",
      "integrity": "sha512-JQ1Jk5G4bGrD4pWJQzWsD8I1n1mgPXq33+/vP4sk8j/z/C2siRuxZtaUA7yMTf71TCZTZl/4e1bfzwUmFb3+rw==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@rollup/rollup-darwin-x64": {
      "version": "4.36.0",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.36.0.tgz",
      "integrity": "sha512-6c6wMZa1lrtiRsbDziCmjE53YbTkxMYhhnWnSW8R/yqsM7a6mSJ3uAVT0t8Y/DGt7gxUWYuFM4bwWk9XCJrFKA==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@rollup/rollup-linux-arm64-gnu": {
      "version": "4.36.0",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.36.0.tgz",
      "integrity": "sha512-KqjYVh3oM1bj//5X7k79PSCZ6CvaVzb7Qs7VMWS+SlWB5M8p3FqufLP9VNp4CazJ0CsPDLwVD9r3vX7Ci4J56A==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-arm64-musl": {
      "version": "4.36.0",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.36.0.tgz",
      "integrity": "sha512-QiGnhScND+mAAtfHqeT+cB1S9yFnNQ/EwCg5yE3MzoaZZnIV0RV9O5alJAoJKX/sBONVKeZdMfO8QSaWEygMhw==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-x64-gnu": {
      "version": "4.36.0",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.36.0.tgz",
      "integrity": "sha512-5KtoW8UWmwFKQ96aQL3LlRXX16IMwyzMq/jSSVIIyAANiE1doaQsx/KRyhAvpHlPjPiSU/AYX/8m+lQ9VToxFQ==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-linux-x64-musl": {
      "version": "4.36.0",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.36.0.tgz",
      "integrity": "sha512-sycrYZPrv2ag4OCvaN5js+f01eoZ2U+RmT5as8vhxiFz+kxwlHrsxOwKPSA8WyS+Wc6Epid9QeI/IkQ9NkgYyQ==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@rollup/rollup-win32-arm64-msvc": {
      "version": "4.36.0",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.36.0.tgz",
      "integrity": "sha512-qbqt4N7tokFwwSVlWDsjfoHgviS3n/vZ8LK0h1uLG9TYIRuUTJC88E1xb3LM2iqZ/WTqNQjYrtmtGmrmmawB6A==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@rollup/rollup-win32-x64-msvc": {
      "version": "4.36.0",
      "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.36.0.tgz",
      "integrity": "sha512-aRXd7tRZkWLqGbChgcMMDEHjOKudo1kChb1Jt1IfR8cY/KIpgNviLeJy5FUb9IpSuQj8dU2fAYNMPW/hLKOSTw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },

环境

shell 复制代码
C:\workspace\app-ems-global-admin\app>node -v
v22.13.0

C:\workspace\app-ems-global-admin\app>npm -v
10.9.2
相关推荐
mONESY25 分钟前
从 RAG 到 Agentic RAG:固定流程的五个毛病,和把它拆成一张图
javascript
梦帮科技27 分钟前
从 Guest 到 Platinum:Prompt 配额、API Key 与访问控制的安全闭环
javascript·git·架构·node.js·reactjs·html5·visual studio
linux_cfan31 分钟前
videojs v10 源代码系列解读:10 · `DestroyMixin`:双重 rAF 延迟销毁
前端·javascript·音视频
雪芽蓝域zzs39 分钟前
第四十六节:顶部【驾驶舱】独立大屏页面实现
前端·javascript·vue.js
右耳朵猫AI1 小时前
Node.js周刊2026W37 | 三处进程崩溃修复、fs 内置 glob、Workers 模块注册表、Vitest 5.0
javascript·后端·node.js
右耳朵猫AI1 小时前
Web前端周刊2026W37 | Shopify 转原生、React 编译 Rust 化、Vitest 5.0、Rslib 1.0
前端·javascript·react.js·typescript·node.js
雪芽蓝域zzs2 小时前
第四十八节:驾驶舱大屏进阶:数字滚动动画 + 渐变边框美化
前端·javascript·vue.js
Bingo_BIG2 小时前
LOV列表的查询
前端·javascript·lov
小静AI工程实验室3 小时前
JS 逆向接口 ID 变了?Python 与 Node.js 复现 JSON 大整数精度丢失
javascript·python·node.js
刘发财11 小时前
前端2秒生成500页矢量PDF,rust真的强到没朋友
前端·javascript·rust