Nuxt 3.3.2 Node_modules 路径错误

问题描述 投票:0回答:2

我的nuxt有问题,当我使用命令

npm run dev
时,它抛出了这个错误
ERROR  Failed to load url /@fs/Users/krzysztofjust/node_modules/hookable/dist/index.mjs?v=d68fa752 (resolved id: /Users/krzysztofjust/node_modules/hookable/dist/index.mjs?v=d68fa752) in /Users/krzysztofjust/node_modules/nuxt/dist/app/nuxt.js. Does the file exist?
,我尝试删除node_modules,package-lock.json,并使用
npm i
,但仍然出现错误。

该项目在我的旧电脑上运行,目前在 Macbook Air M1 上运行

npm 版本:8.19.3

节点版本:18.13.0

我的package.json

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare",
    "generate-icons": "node assets/generate-icons/generate.js",
    "lintfix": "eslint --fix --ext \".ts,.js,.vue\" --ignore-path .gitignore .",
    "lint:js": "eslint --ext \".ts,.js,.vue\" --ignore-path .gitignore .",
    "lint:style-test": "stylelint **/*.{vue,css,scss} --ignore-path .gitignore",
    "lint:style": "stylelint **/*.{css,scss} --ignore-path .gitignore",
    "lint": "npm run lint:js && npm run lint:style"
  },
  "dependencies": {
    "@nuxtjs/i18n": "8.0.0-beta.9",
    "@nuxtjs/robots": "^3.0.0",
    "@pinia/nuxt": "^0.4.7",
    "fantasticon": "^2.0.0",
    "gardevoir": "^1.0.0",
    "jwt-decode": "^3.1.2",
    "pinia": "^2.0.33",
    "vee-validate": "^4.8.4",
    "vite-svg-loader": "^4.0.0"
  },
  "devDependencies": {
    "@nuxt/content": "^2.5.2",
    "@typescript-eslint/eslint-plugin": "^5.57.0",
    "@typescript-eslint/parser": "^5.57.0",
    "@vue/eslint-config-standard": "^8.0.1",
    "eslint": "^8.37.0",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-nuxt": "^4.0.0",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-vue": "^9.10.0",
    "prettier": "^2.8.7",
    "sass": "^1.60.0",
    "sass-loader": "^13.2.2",
    "stylelint": "^15.3.0",
    "stylelint-config-prettier-scss": "^0.0.1",
    "stylelint-config-standard-scss": "^7.0.1",
    "stylelint-prettier": "^3.0.0",
    "typescript": "^5.0.2"
  }
}
node-modules npm-install nuxt3
2个回答
0
投票

这个错误是我的疏忽造成的,nuxt是全局安装的,使得路径为

node_modules
,从主目录获取,问题解决,我全局卸载了nuxt,只安装在项目中。


0
投票

有同样的错误。就我而言,我在 /Users/username 中有一个随机的

node_modules
文件夹。它不会出现在
npm ls -g
npm root -g
中,但在运行时仍然被一些包获取
npm run dev

© www.soinside.com 2019 - 2024. All rights reserved.