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

2021-11-17 20:35:20 +08:00
 chenqh
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/

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

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

你用 vite 建一个全新的项目 装 less 试试
codingBug
2021-11-17 23:46:35 +08:00
删掉 node_modules 和 package-lock.json ,再重新安装一遍试试
chenqh
2021-11-18 01:03:14 +08:00
@codingBug 我试一试,我之前没有删除 package-lock.json
chenqh
2021-11-18 01:03:23 +08:00
@codingBug 好像可以了
sam014
2021-11-18 09:47:53 +08:00
最近我也碰到了一些 npm 依赖装不上的问题,最后发现是淘宝源没有同步,换 npm 源没有问题了
chenqh
2021-11-18 10:55:52 +08:00
@sam014 国内除了淘宝源, npm 还有什么源呀, 推荐一个?
CokeMine
2021-11-18 11:27:50 +08:00
null00
2021-11-19 10:03:29 +08:00
命令行翻墙

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/816132

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX