win7安装 高版本 Node.js vue23错误 node:os:68 throw new ERR_SYSTEM_ERROR(ctx); 详情解决办法

在安装Node.jsv18.16.0和npm9.5.1时,针对os模块的错误,文章提供了解决方案:编辑报错文件Defaults.js,在`constos=require(os);`后添加`os.hostname=()=>localhost;`,保存后可成功安装VueCLI。

win764安装 高版本 Node.js vue23 错误 node:os:68 throw new ERR_SYSTEM_ERROR(ctx); 详情解决办法

一、查看报错信息 找出 报错文件 地址

X:/安装文件夹/node/node_global/node_modules/@vue/cli/node_modules/@achrinza/node-ipc/entities/Defaults.js

多半是这个文件出了问题

二、打开该文件

三编辑该文件(定位于 const os = require(‘os’); 之后)

四添加内容

os.hostname=()=>“localhost”;

五 保存 退出

六,完成,安装你的脚手架吧。

本人系统:

win764

node.js V18.16.0

npm 9.5.1

此错误浪费了12个小时,如节省了您的时间,感谢点赞。

<template> <view class="login-container"> <view class="login-form"> <text class="login-title">用户登录</text> <input v-model="username" placeholder="用户名" class="login-input" placeholder-class="input-placeholder" /> <input v-model="password" type="password" placeholder="密码" class="login-input" placeholder-class="input-placeholder" /> <button class="login-button" :loading="loading" @click="handleLogin" >登录</button> </view> </view> </template> <script> import { ref } from 'vue' export default { setup() { const username = ref('') const password = ref('') const loading = ref(false) const handleLogin = async () => { // 验证输入 if (!username.value.trim()) { uni.showToast({ title: '请输入用户名', icon: 'none', duration: 2000 }) return } if (!password.value) { uni.showToast({ title: '请输入密码', icon: 'none', duration: 2000 }) return } loading.value = true try { // 兼容性请求 const response = await new Promise((resolve, reject) => { uni.request({ url: 'http://172.26.26.43/dev-api/login', method: 'POST', data: { username: username.value, password: password.value }, header: { 'Content-Type': 'application/json' }, timeout: 10000, success: (res) => resolve(res), fail: (err) => reject(err) }) }) // 处理响应 await handleResponse(response) } catch (error) { console.error('登录请求出错:', error) let errorMsg = '登录失败,请重试' if (error.errMsg) { errorMsg = `请求失败: ${error.errMsg}` } else if (error.message) { errorMsg = error.message } uni.showToast({ title: errorMsg, icon: 'none', duration: 2000 }) } finally { loading.value = false } } const handleResponse = async (response) => { // 检查HTTP状态码 if (response.statusCode < 200 || response.statusCode >= 300) { throw new Error(`服务器错误: ${response.statusCode}`) } // 解析响应数据 const { data } = response if (!data) { throw new Error('服务器返回空数据') } const { code, message, token } = data if (code === 200) { // 存储token uni.setStorageSync('token', token) uni.showToast({ title: '登录成功!', icon: 'success', duration: 1000 }) // 登录成功后跳转 setTimeout(() => { uni.redirectTo({ url: '/pages/detail/detail?id=123' }) }, 1000) } else { throw new Error(`登录失败: ${message || '未知错误'}`) } } return { username, password, loading, handleLogin } } } </script> <style scoped> .login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 32rpx; background-color: #f5f5f5; } .login-form { width: 100%; max-width: 600rpx; padding: 60rpx; background: #fff; border-radius: 16rpx; box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1); } .login-title { display: block; text-align: center; margin-bottom: 60rpx; font-size: 40rpx; font-weight: bold; color: #333; } .login-input { width: 100%; height: 88rpx; padding: 0 24rpx; margin-bottom: 40rpx; border: 2rpx solid #ddd; border-radius: 12rpx; font-size: 32rpx; box-sizing: border-box; } .input-placeholder { color: #999; font-size: 32rpx; } .login-button { width: 100%; height: 88rpx; line-height: 88rpx; background-color: #007aff; color: white; font-size: 32rpx; border-radius: 12rpx; margin-top: 20rpx; } .login-button:active { background-color: #0062cc; opacity: 0.9; } </style> 报错:09:16:45.721 应用【vue3-uni-mycp】已启动 09:17:07.568 跳转登录页成功 at pages/index/index.vue:16 09:17:17.980 Listener added for a 'DOMNodeInserted' mutation event. Support for this event type has been removed, and this event will no longer be fired. See https://chromestatus.com/feature/5083947249172480 for more information. at __uniappquill.js:7 09:17:22.990 [Vue warn]: Unhandled error during execution of native event handler at <Operation__pageId=4__pagePath="pages/operation/operation"__pageQuery={"id":"11"} ...> 09:17:22.990 TypeError: _ctx.setRating is not a function 09:17:34.523 [Vue warn]: Unhandled error during execution of native event handler at <Operation__pageId=4__pagePath="pages/operation/operation"__pageQuery={"id":"11"} ...> 09:17:34.523 TypeError: _ctx.setScore26 is not a function 09:17:36.069 [Vue warn]: Unhandled error during execution of native event handler at <Operation__pageId=4__pagePath="pages/operation/operation"__pageQuery={"id":"11"} ...> 09:17:36.070 TypeError: _ctx.setRating is not a function 09:17:37.818 App Hide at App.vue:10
最新发布
07-25
评论 9
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值