node:internal/crypto/hash:103 this[kHandle] = new _Hash(algorithm, xofLen, algorithmId, getHashCache()); ^ Error: error:0308010C:digital envelope routines::unsupported

方案一:设置环境变量(推荐,临时解决)

# Linux / macOS
export NODE_OPTIONS=--openssl-legacy-provider

# Windows (PowerShell)
$env:NODE_OPTIONS = "--openssl-legacy-provider"

# Windows (CMD)
set NODE_OPTIONS=--openssl-legacy-provider

正确做法:在 scripts 中设置 NODE_OPTIONS

Windows(CMD)

{
  "scripts": {
    "dev": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
    "build": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build"
  }
}

Linux / macOS(包括大多数 CI 和 HBuilderX、VS Code 终端)

{
  "scripts": {
    "dev": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
    "build": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service build",
    "serve": "NODE_OPTIONS=--openssl-legacy-provider uniapp-cli serve"
  }
}

Comments

No comments yet. Why don’t you start the discussion?

发表回复