“无法读取未定义的属性‘升级’"启动 vue 应用程序时 [英] "Cannot read property 'upgrade' of undefined" when starting vue application

查看:102
本文介绍了“无法读取未定义的属性‘升级’"启动 vue 应用程序时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,它已经完美运行了几个月,能够毫无问题地运行 npm run serve.每当我切换网络时,我都必须终止并再次运行命令,但这从来都不是问题,服务器总是可以再次启动.

I have a project that's been running perfectly for a few months now, able to run npm run serve with no problem. I have to terminate and run the command again whenever I switch networks, but that has never been a problem and the server could always start again.

直到现在 - 无论我做什么,我都无法启动服务器.我收到此错误:

Until now - no matter what I do I can't get the server to start. I get this error:

npm run serve

> xbs@0.6.2 serve D:\workspace\[PROJECT]
> vue-cli-service serve

 INFO  Starting development server...
 10% building 1/1 modules 0 active ERROR  TypeError: Cannot read property 'upgrade' of undefined
TypeError: Cannot read property 'upgrade' of undefined
    at Server.<anonymous> (D:\workspace\[PROJECT]\node_modules\webpack-dev-server\lib\Server.js:667:47)
    at Array.forEach (<anonymous>)
    at new Server (D:\workspace\[PROJECT]\node_modules\webpack-dev-server\lib\Server.js:666:22)
    at serve (D:\workspace\[PROJECT]\node_modules\@vue\cli-service\lib\commands\serve.js:137:20)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
    at Function.Module.runMain (module.js:695:11)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

我上次收到这条消息是在我忘记设置 .env 文件时,但这是一个以前的工作副本,其中设置了所有必需的文件,自上次以来没有任何更改工作运行.

The last time I got this message was when I forgot to set the .env files, but this is a previously working copy with all necessary files set, and no changes since the last working run.

我什至尝试过提取 repo 的新副本,运行 npm i 并设置所有 env 文件,但仍然失败.

I've even tried pulling a fresh copy of the repo, running npm i and setting all env files but it still fails.

npm run lintnpm run build 仍然可以工作,只有 npm run serve.

npm run lint and npm run build can still work, only npm run serve.

我错过了什么吗?

推荐答案

问题再次出现在 .env 文件上.我的 vue.config.js 试图访问之前设置的环境变量,该变量已被删除.

The problem was again with the .env files. My vue.config.js was trying to access a previously set environment variable that had since been removed.

唯一奇怪的是到现在为止没有任何问题吗?

Only strange thing was that there weren't any problems up til now?

这篇关于“无法读取未定义的属性‘升级’"启动 vue 应用程序时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆