---
# System prepended metadata

title: vue 遇到的各種問題總結

---

# vue 遇到的各種問題總結

### 解決 無法 npm run electron:build 
* 版本相容性問題

    <font color="blue">node.js 版本要16.0以下 (改版到 v15.14.0)</font>
    參考文章 : https://github.com/electron-userland/electron-builder/issues/5668
    
    為了切換版本可以下載套件，<font color="red">nvm-windows</font>，我下載 1.1.3 版本
    ``
    npm install nvm-windows
    ``
    
    語法 :100: : 
    ` nvm install <version>`    (下載 node.js 的版本)
    ` nvm list` (查看現有的 node.js 版本有哪些)
    ` nvm use <version>` (使用現有的 node.js 版本)
    
* 無法使用 npm 
    參考文章 : https://www.cnblogs.com/jaxu/p/13904018.html
    
    <font color="blue">尋找相對應的 node.js 版本，解壓縮以後照搬 node_modules 到 nvm 路徑底下的對應版本 (ex.我是要載 v.15.14.0)</font>
    
    下載先前的 node.js 版本 : https://nodejs.org/zh-cn/download/releases/
    
    ![](https://i.imgur.com/RN6bIZ3.png)
    
    解壓縮以後，基本上我是把 node_modules 以及有關 npm 的檔案都複製過來了
    再用 `npm -v` 如果有出現版本號就表示安裝成功

* 中文路徑的問題
參考文章 : https://blog.csdn.net/kyq0417/article/details/111266776

* vs code 切換 npm 版本後無法使用 npm 語法

    ![](https://i.imgur.com/LKMlSJO.png)


1.   右鍵系統管理員打開 <font color="red">PowerShell ISE</font>
2.    輸入 `get-executionpolicy`
    看看目前的執行原則是什麼。這時候應該會看到Restricted(因系統預設為這個)
3. 輸入 `set-executionpolicy remotesigned` 
    執行更改為remotesigned，在執行時會跳出警告視窗通知你要是否要改變，按下"是" 
    
      ![](https://i.imgur.com/9f9g73k.png)
      
### build linux 執行檔 遇到錯誤
```
{
  "name": "vue-electron",
  "version": "0.1.0",
  "private": true,
  "author": "haha861924 <qq861924@gmail.com>",
  "homepage": "https://github.com/owner/project#readme",
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "eslint --ext .js,.vue src --fix",
    "electron:build": "vue-cli-service electron:build",
    "electron:serve": "vue-cli-service electron:serve",
    "postinstall": "electron-builder install-app-deps",
    "postuninstall": "electron-builder install-app-deps",
    "build_linux": "electron-packager . vue-electron --platform=linux --arch=x64",
    "build_arm": "electron-packager . vue-electron --platform=linux --arch=armv7l",
    "dist:linux": "electron-builder  --linux"
  },
  "main": "dist_electron\\bundled\\background.js",
  "dependencies": {
    "axios": "^0.21.1",
    "core-js": "^3.6.5",
    "crypto": "^1.0.1",
    "crypto-js": "^4.0.0",
    "dayjs": "^1.10.4",
    "electron-packager": "^15.2.0",
    "electron-store": "^8.0.0",
    "eslint-plugin-vuefix": "^0.2.1",
    "path": "^0.12.7",
    "socket.io-client": "^3.1.0",
    "systeminformation": "^4.34.20",
    "vue": "^2.6.11",
    "vue-router": "^3.2.0",
    "vuetify": "^2.4.9",
    "vuex": "^3.4.0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-vuex": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "@vue/eslint-config-standard": "^5.1.2",
    "babel-eslint": "^10.1.0",
    "electron": "^11.0.0",
    "electron-devtools-installer": "^3.1.0",
    "eslint": "^6.8.0",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-vue": "^6.2.2",
    "mini-css-extract-plugin": "^0.9.0",
    "prettier": "^2.2.1",
    "sass": "^1.32.0",
    "sass-loader": "^10.0.0",
    "vue-cli-plugin-electron-builder": "~2.0.0-rc.6",
    "vue-cli-plugin-vuetify": "~2.3.1",
    "vue-template-compiler": "^2.6.11",
    "vuetify-loader": "^1.7.0",
    "electron-builder": "^22.11.7"
  },
  "linux": {
    "target": "deb"
  },
  "deb": {},
  "build": {
    "productName": "vue-electron",
    "appId": "com.vue-electron.app",
    "directories": {
      "output": "build"
    },
    "linux": {
      "target": "deb"
    }
  }
}

```

結論 : electron-build 連線失敗 
