我在运行Vue项目时,提示以下报错信息
不知道是否是因为babel的版本问题,到解析 Promise 的时候就报错了,有谁知道帮忙解答一下,十分感谢
ERROR in ./~/.npminstall/babel-loader/6.2.5/babel-loader!./~/.npminstall/vue-loader/9.7.0/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue
Module not found: Error: Cannot resolve module 'babel-runtime/helpers/extends' in /Users/st/work/vue/Vuex-maizuo/src
@ ./~/.npminstall/babel-loader/6.2.5/babel-loader!./~/.npminstall/vue-loader/9.7.0/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue 7:16-56
ERROR in ./~/.npminstall/babel-loader/6.2.5/babel-loader!./~/.npminstall/vue-loader/9.7.0/vue-loader/lib/selector.js?type=script&index=0!./src/views/home/index.vue
Module not found: Error: Cannot resolve module 'babel-runtime/helpers/extends' in /Users/st/work/vue/Vuex-maizuo/src/views/home
@ ./~/.npminstall/babel-loader/6.2.5/babel-loader!./~/.npminstall/vue-loader/9.7.0/vue-loader/lib/selector.js?type=script&index=0!./src/views/home/index.vue 7:16-56
ERROR in ./src/vuex/modules/film/mutations.js
Module not found: Error: Cannot resolve module 'babel-runtime/helpers/defineProperty' in /Users/st/work/vue/Vuex-maizuo/src/vuex/modules/film
@ ./src/vuex/modules/film/mutations.js 7:23-70
ERROR in ./src/vuex/modules/app/mutations.js
Module not found: Error: Cannot resolve module 'babel-runtime/helpers/defineProperty' in /Users/st/work/vue/Vuex-maizuo/src/vuex/modules/app
@ ./src/vuex/modules/app/mutations.js 7:23-70
ERROR in ./src/vuex/modules/film/actions.js
Module not found: Error: Cannot resolve module 'babel-runtime/core-js/promise' in /Users/st/work/vue/Vuex-maizuo/src/vuex/modules/film
@ ./src/vuex/modules/film/actions.js 8:15-55
.babelrc
{
"presets": ["es2015", "stage-2"],
"plugins": ["transform-runtime"],
"comments": false
}
只引用一个模块也报错
ERROR in ./src/vuex/modules/film/actions.js
Module not found: Error: Cannot resolve module 'babel-runtime/core-js/promise' in /Users/lt/work/vue/Vuex-maizuo/src/vuex/modules/film
@ ./src/vuex/modules/film/actions.js 8:15-55
main.js
import 'babel-polyfill'
import Vue from 'vue'
import VueRouter from 'vue-router'
import VueResour from 'vue-resource'
import FastClick from 'fastclick'
// import routerConfig from './routers'
import store from './vuex/store'
// // import App from './App'
//
// Vue.use(VueRouter)
// Vue.use(VueResource)
// const router = new VueRouter({routes: routerConfig})
/* eslint-disable no-new */
new Vue({
el: '#app',
// router,
// store,
// render: h => h(App),
});
//
// window.addEventListener('load', ()=>{
// FastClick.attach(document.body)
// })
报错的模块actions.js
import Vue from 'vue'
/**
* [_get 异步获取数据公共方法]
* @param {[String]} options.url [api地址]
* @param {[String]} options.query [查询参数]
* @return {[Promise]} [Promise]
*/
const _get = ({url, query}, commit) => {
if(commit) commit('START_LOADING')
let _url
if(query){
_url = `http://m.maizuo.com/v4/api${url}?${query}`
} else {
_url = `http://m.maizuo.com/v4/api${url}`
}
return Vue.http.get(_url)
.then((res)=>{
if( commit ) commit('FINISH_LOADING')
if(res.status >= 200 && res.status < 300){
return res.data
}
return Promise.reject(new Error(res.status))
})
}
promis这个模块是有的
https://github.com/babel/babe...
你需要安装多一个
babel-runtime
。