Node Vue 项目开发常见问题解决

记录平时Node Vue 项目开发中遇到问题及解决方案,不喜勿喷

目录

[一、Nodejs 安装](#一、Nodejs 安装)

[二、NPM 设置镜像代理](#二、NPM 设置镜像代理)

[三、解决node升级到18 的问题](#三、解决node升级到18 的问题)

[四、resolutions 解决包冲突问题](#四、resolutions 解决包冲突问题)

五、core-js安装后,运行报错


一、Nodejs 安装

Nodejs 下载

或是使用NVM管理nodejs 版本

NVM下载

二、NPM 设置镜像代理

复制代码
npm config set registry https://registry.npmmirror.com   
npm config set registry cls
npm config get registry

淘宝镜像仓库(国内):https://registry.npmmirror.com

华为镜像仓库(国内):https://repo.huaweicloud.com/repository/npm/

清华镜像仓库 :https://mirrors.tuna.tsinghua.edu.cn/

三、解决node升级到18 的问题

1、增加一项 NODE_OPTIONS=--openssl-legacy-provider

复制代码
// 运行配置
NODE_OPTIONS=--openssl-legacy-provider
或  
SET NODE_OPTIONS=--openssl-legacy-provider
 如:"dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --open --copy",
  1. 使用 sass 代替 node-sass,这里需要注意版本 sass 与 sass-loader 版本

    npm unintall node-sass
    npm install sass -D

四、resolutions 解决包冲突问题

问题:yarn insntall 报错,显示 @achrinza/node-ipc@9.2.2 不支持现在的node版本

复制代码
error @achrinza/node-ipc@9.2.2: The engine "node" is incompatible with this module. Expected version "8 || 10 || 12 || 14 || 16 || 17". Got "18.10.0"
error Found incompatible module.

resolutions 是一个用于解决依赖项冲突的 npm 特殊字段。在某些情况下,项目依赖项可能需要不同的版本,而这些版本之间可能存在冲突。

复制代码
## package.json中 添加 @achrinza/node-ipc
{
  "name": "my-project",
  "version": "1.1.0",
  "scripts": {
    ....
  },
  "dependencies": {
   ....
  },
  "devDependencies": {
      ....
  },
  

"engines": {},
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ],
  
    //添加  @achrinza/node-ipc
  "resolutions": {
    "@achrinza/node-ipc": "9.2.9"
  }
}

五、core-js安装后,运行报错

复制代码
$ vue-cli-service serve
 INFO  Starting development server...
98% after emitting CopyPlugin

 ERROR  Failed to compile with 162 errors                               15:07:00

These dependencies were not found:

* core-js/modules/es.iterator.constructor.js in ./node_modules/@babel/runtime/helpers/objectSpread2.js, ./node_modules/quill/blots/block.js and 54 others
* core-js/modules/es.iterator.every.js in ./node_modules/quill/modules/keyboard.js, ./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/components/Tinymce/components/EditorImage.vue?vue&type=script&lang=js and 2 others
* core-js/modules/es.iterator.filter.js in ./node_modules/@babel/runtime/helpers/objectSpread2.js, ./node_modules/quill/blots/scroll.js and 12 others
* core-js/modules/es.iterator.find.js in ./node_modules/quill/blots/scroll.js, ./node_modules/quill/core/composition.js and 5 others
* core-js/modules/es.iterator.for-each.js in ./node_modules/@babel/runtime/helpers/objectSpread2.js, ./node_modules/quill/blots/block.js and 24 others
* core-js/modules/es.iterator.map.js in ./node_modules/quill/blots/block.js, ./node_modules/quill/core/editor.js and 36 others
* core-js/modules/es.iterator.reduce.js in ./node_modules/quill/blots/block.js, ./node_modules/quill/core/quill.js and 4 others
* core-js/modules/es.iterator.some.js in ./node_modules/quill/blots/cursor.js, ./node_modules/quill/core/selection.js and 9 others

To install them, you can run: npm install --save core-js/modules/es.iterator.constructor.js core-js/modules/es.iterator.every.js core-js/modules/es.iterator.filter.js core-js/modules/es.iterator.find.js core-js/modules/es.iterator.for-each.js core-js/modules/es.iterator.map.js core-js/modules/es.iterator.reduce.js core-js/modules/es.iterator.some.js

1、首先检查 package.json 中是有 core-js 以及版本 如: "core-js": "3.37.1"

2 、检查node-modules 目录中是否存在 core-js 及版本

如果版本不一样,需要删除重新安装

复制代码
npm uninstall core-js  或 yarn remove core-js
删除node-modules 中 core-js 文件夹
或按下步骤执行:
1、先删除 node_modules 依赖
    npm rm -rf node_modules 
  或 
   yarn remove node_modules
2、首先安装 报错的插件
    npm install --save core-js
    或
    yarn add --save core-js
3、最后再 npm install 或者 yarn install
     npm install 
     或
     yarn install
4、最后 npm run dev 运行启动
     npm run dev
     或
     yarn dev
相关推荐
吃好睡好便好13 分钟前
在Matlab中用sphere( )函数绘制球面图
开发语言·前端·javascript·学习·算法·matlab·信息可视化
黑贝是条狗15 分钟前
注册表破解chrome,edge阻止浏览器连接本地websocket
前端·javascript·数据库
UXbot17 分钟前
AI 原型工具对比(2026):从文字描述到完整 App 界面的 5 款主流平台评测
android·前端·ios·交互·软件构建
ZC跨境爬虫20 分钟前
跟着 MDN 学 HTML day_53:(深入理解 XPathResult 接口)
前端·javascript·ui·html·音视频
摸鱼仙人~23 分钟前
html-anything 仓库全面介绍
前端·html
长沙红胖子Qt23 分钟前
关于 sourceTree桥接管理远端svn仓库出现git时区差8小时无法同步 的解决方法
git·svn·时间差·8小时
weelinking24 分钟前
2026年三大主流大模型深度对比:GPT-5.5、Claude 4.6与DeepSeek V4谁更值得选择?
java·大数据·人工智能·git·python·gpt·github
之歆26 分钟前
DAY_24JavaScript 面向对象深度全解:Object、构造函数与 this 系统指南(上)
开发语言·前端·javascript·原型模式
梦梦代码精29 分钟前
开源智能体平台 BuildingAI 深度解析:Monorepo 架构、MCP 集成及 GPT-Image-2 接入实测
前端·人工智能·后端·gpt·开源·github
Asurplus32 分钟前
【VUE】17、使用JSEncrypt对数据加解密
javascript·vue.js·jsencrypt·rsa