V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
chenqh
V2EX  ›  Vue.js

问个 npm 和 ant-design-vue 的问题

  •  
  •   chenqh · 2021-11-17 20:35:20 +08:00 · 2459 次点击
    这是一个创建于 1080 天前的主题,其中的信息可能已经有所发展或是发生改变。
    7:46:30 PM [vite] Internal server error: Preprocessor dependency "less" not found. Did you install it?
      Plugin: vite:css
      File: /home/vagrant/jscode/pear-admin-ant/node_modules/ant-design-vue/dist/antd.less
          at loadPreprocessor (/home/vagrant/jscode/pear-admin-ant/node_modules/vite/dist/node/chunks/dep-874085d4.js:34385:15)
          at less (/home/vagrant/jscode/pear-admin-ant/node_modules/vite/dist/node/chunks/dep-874085d4.js:34483:22)
          at compileCSS (/home/vagrant/jscode/pear-admin-ant/node_modules/vite/dist/node/chunks/dep-874085d4.js:34127:40)
          at async TransformContext.transform (/home/vagrant/jscode/pear-admin-ant/node_modules/vite/dist/node/chunks/dep-874085d4.js:33776:50)
          at async Object.transform (/home/vagrant/jscode/pear-admin-ant/node_modules/vite/dist/node/chunks/dep-874085d4.js:50353:30)
          at async transformRequest (/home/vagrant/jscode/pear-admin-ant/node_modules/vite/dist/node/chunks/dep-874085d4.js:65394:29)
          at async viteTransformMiddleware (/home/vagrant/jscode/pear-admin-ant/node_modules/vite/dist/node/chunks/dep-874085d4.js:65522:32)
    

    node: v16.9.0

    配置信息

     "dependencies": {
        "@ant-design-vue/use": "^0.0.1-alpha.10",
        "@ant-design/icons-vue": "^6.0.1",
        "@antv/g2": "^4.1.20",
        "@vitejs/plugin-vue": "^1.6.2",
        "ant-design-vue": "^2.2.8",
        "axios": "^0.21.1",
        "core-js": "^3.6.5",
        "lodash.get": "^4.4.2",
        "moment": "^2.27.0",
        "nprogress": "^0.2.0",
        "path": "^0.12.7",
        "rollup-plugin-visualizer": "^5.5.2",
        "vue": "^3.2.21",
        "vue-i18n": "^9.1.7",
        "vue-router": "^4.0.10",
        "vuex": "^4.0.2"
      },
      "devDependencies": {
        "@babel/eslint-parser": "^7.15.8",
        "@types/node": "^14.17.9",
        "@vue/compiler-sfc": "^3.2.21",
        "@zougt/vite-plugin-theme-preprocessor": "^1.3.12",
        "babel-plugin-import": "^1.13.3",
        "eslint": "^6.8.0",
        "eslint-plugin-vue": "^7.18.0",
        "less": "^4.1.2",
        "less-loader": "^10.2.0",
        "mockjs2": "^1.0.8",
        "node-sass": "^6.0.0",
        "rollup-plugin-analyzer": "^4.0.0",
        "sass-loader": "^10.0.2",
        "vite": "^2.5.8"
      },
    

    尝试的方案

    1. npm install less less-loadernpm install less less-loader -D 都没有效果, 删除 node_modules, 在运行这些命令也一样

    2. 替换 registry, 在运行 1 的命令也没有效果

    vagrant@ubuntu:~/jscode/pear-admin-ant$ npm get registry
    http://registry.npmmirror.com/
    

    所以到底怎么搞呢兄弟们?

    10 条回复    2021-11-19 10:03:29 +08:00
    lupkcd
        1
    lupkcd  
       2021-11-17 22:58:06 +08:00
    vite 自带 loader 只需要装 less
    chenqh
        2
    chenqh  
    OP
       2021-11-17 23:25:15 +08:00
    @lupkcd 所以怎么装呀 我 npm install less 没有作用呀?
    lupkcd
        3
    lupkcd  
       2021-11-17 23:33:41 +08:00
    @chenqh #2 vite 用 antv less 是可以的 应该是你哪里出问题了

    你用 vite 建一个全新的项目 装 less 试试
    codingBug
        4
    codingBug  
       2021-11-17 23:46:35 +08:00 via Android   ❤️ 1
    删掉 node_modules 和 package-lock.json ,再重新安装一遍试试
    chenqh
        5
    chenqh  
    OP
       2021-11-18 01:03:14 +08:00
    @codingBug 我试一试,我之前没有删除 package-lock.json
    chenqh
        6
    chenqh  
    OP
       2021-11-18 01:03:23 +08:00
    @codingBug 好像可以了
    sam014
        7
    sam014  
       2021-11-18 09:47:53 +08:00
    最近我也碰到了一些 npm 依赖装不上的问题,最后发现是淘宝源没有同步,换 npm 源没有问题了
    chenqh
        8
    chenqh  
    OP
       2021-11-18 10:55:52 +08:00
    @sam014 国内除了淘宝源, npm 还有什么源呀, 推荐一个?
    CokeMine
        9
    CokeMine  
       2021-11-18 11:27:50 +08:00 via Android   ❤️ 1
    null00
        10
    null00  
       2021-11-19 10:03:29 +08:00
    命令行翻墙
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2730 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 12:34 · PVG 20:34 · LAX 05:34 · JFK 08:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.