Vue中"This dependency was not found"问题的解决方法

今天在初始化项目中,出现了一个奇怪的情况:明明路径是对的,但是编译的时候,一直报“This dependency was not found”的错。

代码如下:

import Vue from 'vue'
import App from './App'
import router from './router'
import 'common/stylus/index.styl'
/* eslint-disable no-new */
new Vue({
 el: '#app',
 render: h => h(App)
})

控制台一直报错,表示无法找到common/stylus/index.styl,然而,路径是通过ide补全填写的,不可能出现错误,那又是为什么?

在网上多番搜索发现,Vue中的引入文件时,需要通过./通知编译器是在当前路径,不然的话,第一个文件夹名会被认为是webpack配置的alias(别名)。

所以,正确引入index.styl的方式是:

import Vue from 'vue'
import App from './App'
import router from './router'
import './common/stylus/index.styl' // 添加./避免编译器认为是别名
/* eslint-disable no-new */
new Vue({
 el: '#app',
 render: h => h(App)
})

总结

以上所述是小编给大家介绍的Vue中"This dependency was not found"的问题的解决方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对呐喊教程网站的支持!

声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:notice#nhooo.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。