Nuxt 在 M1 Chip Mac 上构建太慢

bat*_*tch 5 node.js typescript vue.js nuxt.js apple-m1

我正在我的新 M1 芯片机器(Mac)上为 Nuxt 项目开发环境。\n问题是 Nuxt 项目的构建速度太慢。

\n

我将nodenv安装到我的项目中,并使用v12.9.0。在项目文件夹中,使用的包 maneger(npm / yarn) 位于/Users/username/.nodenv/shims/node.

\n

我运行yarn install和后yarn dev,编译(客户端加服务器)大约需要 2 小时。

\n

如果我在我的英特尔机器(Mac)上运行yarn dev,构建只需要几秒钟。

\n

如果您对隔离问题的步骤有任何想法,请教我。\n谢谢,

\n

\xe3\x80\x90我的方法\xe3\x80\x91

\n
    \n
  • 删除node_modules并重新安装它们yarn install
  • \n
  • 重新启动我的机器
  • \n
  • 简单的 nuxt 项目与 Intel 机器上的运行方式相同
  • \n
\n

\xe3\x80\x90环境\xe3\x80\x91

\n
    \n
  • M1芯片机
  • \n
  • nodenv(自制)
  • \n
  • nuxt / vue 项目
  • \n
\n

\xe3\x80\x90modules\xe3\x80\x91\nmy package.json 是这样的,

\n
"dependencies": {\n    "@nuxt/typescript-runtime": "^0.4.0",\n    "@nuxtjs/axios": "^5.9.5",\n    "@nuxtjs/dotenv": "^1.4.1",\n    "@nuxtjs/google-gtag": "^1.0.4",\n    "@nuxtjs/gtm": "^2.4.0",\n    "@nuxtjs/pwa": "^3.0.0-0",\n    "@nuxtjs/style-resources": "^1.0.0",\n    "@types/highlight.js": "^9.12.3",\n    "@types/quill": "^2.0.3",\n    "autolinker": "^3.13.0",\n    "blob-util": "^2.0.2",\n    "camelcase-keys": "^6.2.1",\n    "cross-env": "^7.0.2",\n    "crypto-js": "^4.0.0",\n    "express": "^4.17.1",\n    "highlight.js": "^9.18.1",\n    "js-cookie": "^2.2.1",\n    "npm-check-updates": "^4.0.6",\n    "nuxt": "^2.12.1",\n    "nuxt-basic-auth-module": "^1.3.2",\n    "nuxt-clipboard2": "^0.2.1",\n    "parchment": "^2.0.0-dev.2",\n    "pm2": "^4.2.3",\n    "quill-image-drop-and-paste": "^1.0.4",\n    "sanitize-html": "^1.22.1",\n    "snakecase-keys": "^3.1.2",\n    "vue-infinite-loading": "^2.4.5",\n    "vue-property-decorator": "^8.4.1",\n    "vue-sanitize": "^0.2.0",\n    "vue-scrollto": "^2.18.1",\n    "vue-stripe-elements-plus": "^0.3.2",\n    "vue-toc": "0.0.1",\n    "vue-tweet-embed": "^2.4.0",\n    "vue2-editor": "^2.10.2",\n    "vuex-persistedstate": "^3.0.0"\n  },\n  "devDependencies": {\n    "@nuxt/typescript-build": "^0.6.0",\n    "@nuxtjs/eslint-config": "^5.0.0",\n    "@nuxtjs/eslint-config-typescript": "^5.0.0",\n    "@nuxtjs/eslint-module": "^3.0.1",\n    "@nuxtjs/moment": "^1.6.0",\n    "@nuxtjs/vuetify": "^1.11.0",\n    "@types/jest": "^25.1.4",\n    "@typescript-eslint/eslint-plugin": "^2.25.0",\n    "@typescript-eslint/parser": "^2.25.0",\n    "@vue/test-utils": "^1.0.0-beta.29",\n    "babel-core": "^7.0.0-bridge.0",\n    "babel-eslint": "^10.1.0",\n    "babel-jest": "^25.2.1",\n    "eslint": "^7.14.0",\n    "eslint-config-prettier": "^6.15.0",\n    "eslint-plugin-nuxt": "^2.0.0",\n    "eslint-plugin-prettier": "^3.1.4",\n    "jest": "^25.2.1",\n    "node-sass": "^4.13.1",\n    "nodemon": "^2.0.2",\n    "prettier": "^2.2.0",\n    "sass-loader": "^8.0.2",\n    "ts-jest": "^25.2.1",\n    "vue-jest": "^3.0.5"\n  }\n
Run Code Online (Sandbox Code Playgroud)\n

bat*_*tch 1

我自己解决了这个问题。

  1. 使用版本节点16.0.0
  2. 如果使用node-sass,请将其删除。
  3. 相反,安装sassnode-loader@7.1.0
  4. yarn install&yarn dev

这对我来说非常有效。