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

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

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补全填写的,不可能出现错误,那又是为何?webpack

屡次测试发现,Vue中的引入文件时,须要经过./通知编译器是在当前路径,否则的话,第一个文件夹名会被认为是webpack配置的alias(别名)。web

因此,正确引入index.styl的方式是:app

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)
})
相关文章
相关标签/搜索