我的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"
}
}
这个错误是我的疏忽造成的,nuxt是全局安装的,使得路径为
node_modules
,从主目录获取,问题解决,我全局卸载了nuxt,只安装在项目中。
有同样的错误。就我而言,我在 /Users/username 中有一个随机的
node_modules
文件夹。它不会出现在npm ls -g
或npm root -g
中,但在运行时仍然被一些包获取npm run dev