问答详情
源自:4-1 项目环境配置

按推荐按需引入vant启动服务时依然报找不到vant的两个相关依赖

"dependencies": {

"axios": "^0.19.0",

"core-js": "^2.6.5",

"vant": "^2.0.9",

"vue": "^2.6.10",

"vue-router": "^3.0.3",

"vuex": "^3.0.1"

},

"devDependencies": {

"@vue/cli-plugin-babel": "^3.9.0",

"@vue/cli-plugin-eslint": "^3.9.0",

"@vue/cli-service": "^3.9.0",

"@vue/eslint-config-prettier": "^4.0.1",

"babel-eslint": "^10.0.1",

"babel-plugin-import": "^1.12.0",

"eslint": "^5.16.0",

"eslint-plugin-vue": "^5.0.0",

"sass": "^1.18.0",

"sass-loader": "^7.1.0",

"vue-template-compiler": "^2.6.10"

}

以上可以看到我的全局dependency中已成功安装vant 2.0.9 而开发环境已成功安装babel-plugin-import 1.12.0

module.exports = {

presets: ["@vue/app"],

plugins: [

['import', {

libraryName: 'vant',

libraryDirectory: 'es',

style: true

}, 'vant']

]

};

而对应的babel.config.js文件也添加了vant的plugin如上图

<template>

<div>

<van-button type="primary">Primary</van-button>

</div>

</template>


<script>

import axios from 'axios';

import {Button} from 'vant';


export default {

name: 'contatcList',

components: {

[Button.name] : Button

},

created() {

}

}

</script>

最后也在相应的自定义组件ContactList.vue中import且在components中注册并在template中使用 可起服务的时候依然报找不到vant对应的两个依赖 不知道哪位大神能帮忙解答 感激涕零>_<

These dependencies were not found:


* vant/es/button in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0

-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/ContactList.vue?vue&type=script&lang=js&

* vant/es/button/style in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??

ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/ContactList.vue?vue&type=script&lang=js&


To install them, you can run: npm install --save vant/es/button vant/es/button/style


P.S.: 即使我尝试了跑以上推荐的命令 npm install --save vant/es/button vant/es/button/style 依然还是会报错 所以只好post在这里看大家有没有遇到过类似的问题了>_<

提问者:慕粉3960250 2019-08-01 16:00

个回答

  • 精慕门0373414
    2020-04-14 11:52:41

    有同样的问题

  • qq_不悔梦归处_0
    2019-10-22 17:07:15

    我重新执行npm install就可以解决,大家可以试一下

  • Lkkpower
    2019-09-02 15:39:54

    求答案,解决了?

  • 詹姆斯周
    2019-08-02 08:56:33

    百度搜索下