记录一个vue项目报错UnhandledPromiseRejectionWarning: Unhandled promise rejection.
使用vue-cli创建vue项目,加入一些之前的代码,然后打包运行报错:
(node:4892) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing insi
de of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejectionid: 1)
(node:4892) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejectionsthat are not handled will terminate the Node.js process with a non-zero exit code.// 然后加卡在这里不动了
18% building modules 72/73 modules 1 active ...ce-demo\weixin-vioce-demo\src\App.vue
网上查阅了很多的资料,下面是我整理的解决方案:
- 在build文件夹下找到webpack.base.conf.js
然后修改加入const vueLoaderPlugin = require(‘vue-loader/lib/plugin’)
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
//加入的
const vueLoaderPlugin = require('vue-loader/lib/plugin')
- 在module.exports中引入 plugins:[new vueLoaderPlugin()]
plugins:[new vueLoaderPlugin()]
- 下面是我的文件的完整代码
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
const vueLoaderPlugin = require('vue-loader/lib/plugin')function resolve (dir) {return path.join(__dirname, '..', dir)
}
module.exports = {context: path.resolve(__dirname, '../'),entry: {app: './src/main.js'},output: {path: config.build.assetsRoot,filename: '[name].js',publicPath: process.env.NODE_ENV === 'production'? config.build.assetsPublicPath: config.dev.assetsPublicPath},resolve: {extensions: ['.js', '.vue', '.json'],alias: {'vue$': 'vue/dist/vue.esm.js','@': resolve('src'),}},module: {rules: [{test: /\.vue$/,loader: 'vue-loader',options: vueLoaderConfig},{ test: /\.js$/,loader: 'babel-loader',include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]},{test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,loader: 'url-loader',options: {limit: 10000,name: utils.assetsPath('img/[name].[hash:7].[ext]')}},{test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,loader: 'url-loader',options: {limit: 10000,name: utils.assetsPath('media/[name].[hash:7].[ext]')}},{test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,loader: 'url-loader',options: {limit: 10000,name: utils.assetsPath('fonts/[name].[hash:7].[ext]')}},{test: /\.sass$/,loaders: ['style', 'css', 'sass']},{test:/\.style$/,use:['style-loader','css-loader']}]},node: {// prevent webpack from injecting useless setImmediate polyfill because Vue// source contains it (although only uses it if it's native).setImmediate: false,// prevent webpack from injecting mocks to Node native modules// that does not make sense for the clientdgram: 'empty',fs: 'empty',net: 'empty',tls: 'empty',child_process: 'empty'},plugins:[new vueLoaderPlugin()]
}
当以上解决之后再运行项目一般来说已经可以了,但是我这个项目还不行,继续其他错误
$ webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
internal/modules/cjs/loader.js:638throw err; ^
Error: Cannot find module 'vue-loader/lib/plugin'at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)at Function.Module._load (internal/modules/cjs/loader.js:562:25)at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18)at Object.<anonymous> (D:\HBuilderProjects\baidu-vioce-demo\weixin-vioce-demo\build\webpack.base.conf.js:6:25)at Module._compile (internal/modules/cjs/loader.js:776:30)at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)at Module.load (internal/modules/cjs/loader.js:653:32)at tryModuleLoad (internal/modules/cjs/loader.js:593:12)at Function.Module._load (internal/modules/cjs/loader.js:585:3)
这种错误其实网上有很多解决方法
主要的就是将对应的版本更新一下,就是对应的vue-loader这个插件的lib下面没有对应的plugin文件,具体做法:
升级了一下 “vue-loader”: “^15.7.0” 就好了
真棒!!
记录一个vue项目报错UnhandledPromiseRejectionWarning: Unhandled promise rejection.相关推荐
- 解决Vue项目报错:Expected indentation of 2 spaces but found 4. eslint(indent) [8, 1]的方法
解决Vue项目报错:Expected indentation of 2 spaces but found 4. eslint(indent) [8, 1]的方法 报错如下 问题分析 明显从图中可以以看 ...
- 前端开发:Vue项目报错Unknown custom element:XXX - did you register the component correctly…的解决方法丨蓄力计划
导读 Vue项目报错Unknown custom element:XXX - did you register the component correctly-的解决方法. 问题 前段时间在做前端项目 ...
- Vue项目 报错TypeError [ERR INVALID ARG TYPE]: The “path“ argument must be of type string
# Vue项目 报错TypeError [ERR INVALID ARG TYPE]: The "path" argument must be of type string 卡了半 ...
- Vue项目报错:This relative module was not found
Vue项目报错:This relative module was not found 问题如下 解决办法 出现这种错误检查自己的路径问题 我已解决 "./ ":代表当前所在的目录. ...
- 记一次升级node版本后,运行原vue项目报错问题解决方法
记一次升级node版本后,运行原vue项目报错问题解决方法 参考文章: (1)记一次升级node版本后,运行原vue项目报错问题解决方法 (2)https://www.cnblogs.com/happ ...
- vue项目报错,解决Module build failed: Error: Cannot find module ‘node-sass‘ 问题
vue项目报错,解决Module build failed: Error: Cannot find module 'node-sass' 问题 参考文章: (1)vue项目报错,解决Module bu ...
- 启动vue项目报错:npm ERR! enoent ENOENT: no such file or directory, open‘E:xxxx\package.json‘
问题描述:cmd / VSCode 启动vue项目报错:npm ERR! enoent ENOENT: no such file or directory, open'E:xxxx\package.j ...
- Node.js报错:UnhandledPromiseRejectionWarning: Unhandled promise rejection
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throw ...
- Vue. 之 报错 Uncaught (in promise)
Vue. 之 报错 Uncaught (in promise) 在点击同一个URL的时候,会报错如下: 解决方案: 在项目目录下运行 npm i vue-router@3.0 -S 即可. 转载于:h ...
最新文章
- 伍六七带你学算法 入门篇-卡牌分组
- WebForm页面生命周期及asp.net运行机制
- 词云_jieba分词
- 7年工作经验,面试官竟然让我写算法题?
- MIUI V5正式发布 全部功能展示PPT回看
- linux进程通信system v,【linux高级程序设计】(第十一章)System V进程间通信 4
- c语言动态指针数组--一种伪二维数组
- visual studio 2019配置dlib读取jpeg图片
- 做一个网站要多少钱?
- python变现实现新浪微博登陆
- Rant ?? 我爱每一片绿叶
- 点击开关灯效果html,js实现电灯开关效果
- 工程线图中计算机的处理方法,CAD建筑施工图绘制复杂施工放线方法
- 全套3D游戏建模自学资料
- 厦大 1395 组合
- C语言经典练习题(2)——“冒泡排序(Bubble Sort)“
- LINUX修改、增加IP的方法 ifconfig 两个ip地址 配置文件
- 人间,除了生死,一切都不是事
- JavaScript 59 JavaScript 常见错误
- buuctf_Misc-喵喵喵
热门文章
- vuex 中出现[vuex] module namespace not found in mapActions(): money找不到的报错
- 临时记录一次ic卡破解(1)
- 【JavaScript】案例1:使用JS完成注册页面校验
- 大学计算机编程学哪些科目,大学计算机课程学习路线应该是怎么样的呢?
- ensp运行出现please check whether virtual box is installed 解决方法
- ux设计_UX评论模式品牌知道规则并且也打破了规则
- android蓝牙配对 自动联接,如何实现android蓝牙开发 自动配对连接,并不弹出提示框...
- 西南民族大学第十届校赛(同步赛) 个人笔记 题解
- 递归方法——猴子吃桃
- 堪比平板的顶级满血970大屏旗舰解密!荣耀Note10抢先体验!