我正在做一个nuxtjs项目,我突然得到了这个变暖的错误,我搜索找到一个解决方案,但我不能,所以如果有人可以帮助我解决这个问题。
错误消息如下所示。
ERROR in ./.nuxt/client.js friendly-errors 10:51:28
Module build failed (from ./node_modules/@nuxt/webpack/node_modules/babel-loader/lib/index.js): friendly-errors 10:51:28
Error: Cannot find module '@babel/plugin-proposal-private-property-in-object'
Require stack:
下面是我的nuxt.config.js
build: {
babel: {
plugins: [
["@babel/plugin-proposal-private-methods", {loose: true}],
["@babel/plugin-proposal-private-property-in-object", {"loose": true}]
],
}
},
package.json文件
"dependencies": {
"@babel/preset-env": "^7.12.17",
"core-js": "^3.8.3",
"global": "^4.4.0",
"module": "^0.0.1",
"nuxt": "^2.13.3",
"vue-scrollmagic": "^1.0.1"
},
"devDependencies": {
"@babel/plugin-proposal-private-methods": "^7.14.5",
"core-js-compat": "^3.4.7",
"sass": "^1.42.1",
"sass-loader": "^12.1.0",
"webpack": "^5.56.0"
}
下面是整个错误消息
ERROR Failed to compile with 1 errors friendly-errors 10:51:28
ERROR in ./.nuxt/client.js friendly-errors 10:51:28
Module build failed (from ./node_modules/@nuxt/webpack/node_modules/babel-loader/lib/index.js): friendly-errors 10:51:28
Error: Cannot find module '@babel/plugin-proposal-private-property-in-object'
Require stack:
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@babel/core/lib/config/files/plugins.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@babel/core/lib/config/files/index.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@babel/core/lib/index.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@nuxt/webpack/node_modules/babel-loader/lib/index.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@nuxt/webpack/node_modules/loader-runner/lib/loadLoader.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@nuxt/webpack/node_modules/loader-runner/lib/LoaderRunner.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@nuxt/webpack/node_modules/webpack/lib/NormalModule.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@nuxt/webpack/node_modules/webpack/lib/NormalModuleFactory.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@nuxt/webpack/node_modules/webpack/lib/Compiler.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@nuxt/webpack/node_modules/webpack/lib/webpack.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@nuxt/webpack/dist/webpack.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@nuxt/cli/dist/cli-index.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@nuxt/cli/dist/cli.js
- /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/nuxt/bin/nuxt.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at resolve (internal/modules/cjs/helpers.js:94:19)
at resolveStandardizedName (/Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@babel/core/lib/config/files/plugins.js:111:7)
at resolvePlugin (/Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@babel/core/lib/config/files/plugins.js:55:10)
at loadPlugin (/Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@babel/core/lib/config/files/plugins.js:63:20)
at loadPlugin.next (<anonymous>)
at createDescriptor (/Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@babel/core/lib/config/config-descriptors.js:187:16)
at createDescriptor.next (<anonymous>)
at step (/Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/gensync/index.js:261:32)
at evaluateAsync (/Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/gensync/index.js:291:5)
at /Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/gensync/index.js:44:11
at Array.forEach (<anonymous>)
at Function.async (/Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/gensync/index.js:43:15)
at Function.all (/Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/gensync/index.js:216:13)
at Generator.next (<anonymous>)
at createDescriptors (/Users/princebolampembe/MyWork/GithubKusunoki/twin_frontend_copy/twin/node_modules/@babel/core/lib/config/config-descriptors.js:142:41)
friendly-errors 10:51:28
@ multi ./node_modules/@nuxt/components/lib/installComponents.js eventsource-polyfill webpack-hot-middleware/client?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
我试图安装@babel/preset-even 7.12.17,但我没有工作,整个代码看起来不错,但这个问题正在发生,我仍然在更多的研究,但如果有人发现一些东西,请让我知道。感谢我正在使用Nuxt.js版本“1.0.0”
3条答案
按热度按时间bmp9r5qi1#
看起来您使用的
@babel/preset-evn
版本(7.12.17)不包含@babel/plugin-proposal-private-property-in-object
。要么尝试显式地添加它(到package.json
,而不仅仅是你的nuxt配置),要么更新到一个新的babel预设;最新的版本7.15.6,* 确实 * 包含了你想要的插件。gpfsuwkq2#
您可以运行此问题的评论
yarn add @babel/plugin-proposal-private-property-in-object --dev
或
npm install @babel/plugin-proposal-private-property-in-object --dev
z31licg03#
感谢大家,我可以找到一个解决方案,这是旧的nuxt.js版本,所以我删除了我的node_modules文件,删除了我的package-lock.json文件,我运行npm安装,然后我运行npm过时后,我正常运行我的开发,这是完美的。