自定义npm包从vue2升级到vue3遇到的问题解决

1.执行npm run build时报错:

(node:16724) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token '??='

at Loader.moduleStrategy (internal/modules/esm/translators.js:149:18

解决 :更新node版本

查看了我使用的node版本是14.21.3,更新到最新稳定版本20.11.0后重新运行build命令后,不再报错。

2.报错 Uncaught TypeError: Cannot read properties of null (reading 'isCE')

这个问题找了好久,一直不知道什么问题,网上有人说是因为有两个不同的vue包,但是我开发的是一个组件,实际并没有使用到vue,我的package.json文件是这样的,本身打包没有问题,但是在项目通过npm link 当前组件时就出现上诉问题。

解决:

https://github.com/vuejs/core/issues/4344找到了答案

在我开发的自定义包里面加入配置:(我用的是webpack)

typescript 复制代码
externals: [ "vue" ],
3.报错Module not found: Error: [CaseSensitivePathsPlugin] ...\node_modules\Vue\index.js' does not match the corresponding path on disk vue.

添加文件

4.保存时使用eslint规则时,组件的属性换行后缩进位置不对。

保存时,使用eslint规则进行格式化,但是缩进出现如下问题:

解决 :

在eslint的配置想extends中添加plugin:vue/vue3-recommended

相关推荐
LisEcho1 天前
yoyoj-rn — RN 的脚手架工具可以不是 @react-native-community/cli
前端·react native·npm
醉风塘1 天前
NPM:从“模块之痛”到“生态之基”的演化史
前端·npm·node.js
水冗水孚1 天前
通俗易懂地谈谈,前端工程化之自定义脚手架的理解,并附上一个实践案例发布到npm上
javascript·npm·node.js
蚂蚁不吃土&1 天前
cmd powershell svm nodejs npm
前端·npm·node.js
凯小默2 天前
37-实现地图配置项(完结)
echarts·vue3
Lucky_Turtle3 天前
【Node】npm install报错npm error Cannot read properties of null (reading ‘matches‘)
前端·npm·node.js
水冗水孚3 天前
20张图的保姆级教程,记录使用Verdaccio在Ubuntu服务器上搭建Npm私服
npm
凯小默3 天前
36-引入地图
echarts·vue3
Irene19913 天前
npm 完整生命周期脚本及特点
npm·生命周期
凯小默3 天前
【TypeScript+Vue3+Vite+Vue-router+Vuex+Mock 进行 WEB 前端项目实战】学习笔记共 89 篇(完结)
typescript·echarts·mock·vue3·vite·vuex·vue-router