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
相关推荐
xixixin_6 分钟前
【CSS】Ant Design 按钮点击时文字位移问题
前端·javascript·html
Csvn8 分钟前
使用 React Hooks 优化组件性能的 5 个技巧
前端·javascript·react.js
不甜情歌15 分钟前
夯实JS基础:引擎、执行机制与作用域核心解析
javascript
方也_arkling20 分钟前
基于脚手架创建Vue2工程
前端·javascript·vue.js
开维游戏引擎30 分钟前
开维游戏引擎实例:五子棋
javascript·游戏·html·游戏引擎·ai编程
简单不容易42 分钟前
【vue hooks】useScreenOrientation-获取屏幕方向并支持低版本系统
javascript·vue.js
橘哥哥1 小时前
vue中读取静态配置文件中内容
前端·javascript·vue.js
前端小D1 小时前
面向对象编程
开发语言·javascript
进击的尘埃1 小时前
GPU 合成层炸了,页面白屏——从 will-change 滥用聊到层爆炸的治理
javascript