sonofmagic / weapp-tailwindcss

weapp-tailwindcss - bring tailwindcss to weapp ! 把 tailwindcss 原子化思想带入小程序开发吧 !
https://tw.icebreaker.top
MIT License
1.29k stars 92 forks source link

uniapp vue2 报错 webpack module not found #77

Closed jipika closed 2 years ago

jipika commented 2 years ago

在运营的电脑上无法发布,是因为缺少webpack的环境吗

sonofmagic commented 2 years ago

你用的是 hbuilderx 进行发布的,还是用 uni-app cli 进行发布的呀? hbuilderx 进行发布这种情况要显式指定版本:

  "devDependencies": {
    "autoprefixer": "9",
    "postcss": "7",
    "postcss-rem-to-responsive-pixel": "^5.1.3",
    "tailwindcss": "npm:@tailwindcss/postcss7-compat",
    "weapp-tailwindcss-webpack-plugin": "^1.7.0",
    "webpack": "npm:webpack@webpack-4"
  }

参考 uni-app-vue2-tailwind-hbuilder-template

jipika commented 2 years ago

我使用的是hbuilderx发布的,是不是因为电脑上需要装某些环境吗

jipika commented 2 years ago

"devDependencies": { "@tailwindcss/line-clamp": "^0.4.0", "@tailwindcss/typography": "^0.5.2", "cross-env": "^7.0.3", "tailwindcss": "^3.1.2", "tailwindcss-miniprogram-preset": "^2.1.2", "weapp-tailwindcss-webpack-plugin": "^1.7.0", "webpack": "npm:webpack@webpack-4" }, 我只用到了替换转义符的功能不需要postcss在我电脑上运行正常

sonofmagic commented 2 years ago

嗯嗯,hbuilderx 的话,就在 package.json 添加我上面的字段,然后 npm i/ yarn 安装一下,然后进行发布即可

上面那个link里,是配置好的 vue2 hbuilderx模板,可以参考一下

sonofmagic commented 2 years ago

"devDependencies": { "@tailwindcss/line-clamp": "^0.4.0", "@tailwindcss/typography": "^0.5.2", "cross-env": "^7.0.3", "tailwindcss": "^3.1.2", "tailwindcss-miniprogram-preset": "^2.1.2", "weapp-tailwindcss-webpack-plugin": "^1.7.0", "webpack": "npm:webpack@webpack-4" }, 我只用到了替换转义符的功能不需要postcss在我电脑上运行正常

嗯呢,那你把 postcss 相关的去掉好了,其实 postcss 已经内置在 uni-app 框架里面了,我写在外面只是显式指定一下版本罢了,哈哈LOL

jipika commented 2 years ago

11:31:16.615 ERROR Error loading vue.config.js: 11:31:16.616 ERROR Error: Cannot find module 'webpack' 11:31:16.619 Require stack: 11:31:16.620 - E:\git\bbc\h5-bbc\node_modules\weapp-tailwindcss-webpack-plugin\dist\index.js 11:31:16.623 - E:\git\bbc\h5-bbc\vue.config.js 11:31:16.623 - D:\HBuilderX.3.3.4.20211228.full\HBuilderX\plugins\uniapp-cli\node_modules\@vue\cli-service\lib\Service.js 11:31:16.626 - D:\HBuilderX.3.3.4.20211228.full\HBuilderX\plugins\uniapp-cli\bin\uniapp-cli.js 11:31:16.627 Error: Cannot find module 'webpack'

jipika commented 2 years ago

但是在他人电脑上运出现了这个错误,是因为 "webpack": "npm:webpack@webpack-4"这个吗

sonofmagic commented 2 years ago

嗯,可能是,你先看看 node_modules 里有没有 webpack 这个目录,然后再你试试 "webpack":"^4.46.0"

image

jipika commented 2 years ago

ok解决问题了,感谢