最近在用粒谷商城项目练手,学习到P59时引入品牌两个vue文件,重启(npm run dev)项目报错:
ERROR Failed to compile with 2 errors 12:11:59This dependency was not found:* @/components/upload/singleUpload in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/views/modules/product/brand-add-or-update.vueTo install it, you can run: npm install --save @/components/upload/singleUploadThis relative module was not found:* ../common/category-cascader in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/views/modules/product/brand.vue
看到这种报错不要慌,仔细看两个错。第一个错是说在brand-add-or-update.vue没有没找到依赖singleUpload:具体信息如下:
“This dependency was not found: @/components/upload/singleUpload”,安装一个singleUpload或者把谷粒商城前端项目复制一份upload过来就可以了。
报第二个错误信息:
* ../common/category-cascader in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/views/modules/product/brand.vue
在common文件下没有文件“category-cascader.vue”,把谷粒商城的前端项目中这个文件复制过来到common就可以了。注意在brand.vue中引入的category-cascader.vue路径在正确,不然后报以下错误:
所以路径要正确才行。npm run dev,启动界面定如下: