错误类型错误:无法读取未定义的 Vue.js 的属性“版本”

joa*_*ash 6 npm vue.js vue-cli

当我跑步时, npm start 我得到

ERROR  TypeError: Cannot read property 'version' of undefined
TypeError: Cannot read property 'version' of undefined
Run Code Online (Sandbox Code Playgroud)

这发生在我跑完之后

npm install
Run Code Online (Sandbox Code Playgroud)

我试图通过运行来解决这个问题, npm -g install npm@version但它给了我这个错误

npm ERR! code ETARGET
npm ERR! notarget No matching version found for npm@version.
Run Code Online (Sandbox Code Playgroud)

小智 8

您是直接从 3.0 升级依赖项吗?在 v4eslint中需要作为项目本身的依赖项。所以npm install --save-dev eslint@4可以修复警告。

  • 谢谢你!此外,还需要“eslint-plugin-vue”。 (3认同)

aBi*_*uit 2

package.json根据我的经验,如果您的项目文件之一中有导入,但路径不正确,则可能会发生这种情况。
通常,一些与构建相关的配置version使用package.json.
由于没有提供具体细节,因此很难查明确切的问题。
首先,我将搜索错误的堆栈跟踪以找到正在请求的文件package.json。全局项目搜索.version也应该有助于找到问题。

如果您仍然无法找到问题,请添加完整的错误堆栈跟踪。