解决vue2配置路由时出现的报错
解决vue2配置路由时出现的报错Uncaught TypeError: Object(...) is not a functionnpm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVers
执行命令npm i vue-router安装路由,运行项目出现报错:Uncaught TypeError: Object(...) is not a function
原因:路由版本过高,默认安装的路由版本为最新版本,而vue2应该安装3版本的vue-router才能正常使用。
解决办法:卸载路由,指定版本安装vue-router。
执行命令npm i vue-router@3重新安装后出现新的报错:
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: vue-loader-v16@npm:vue-loader@16.3.0 (node_modules\vue-loader-v16):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Invalid dependency type requested: alias
npm ERR! path D:\testvue\vue2_test\node_modules\.bin\eslint.cmd
npm ERR! code EEXIST
npm ERR! Refusing to delete D:\testvue\vue2_test\node_modules\.bin\eslint.cmd: is outside D:\testvue\vue2_test\node_modules\eslint and not a link
npm ERR! File exists: D:\testvue\vue2_test\node_modules\.bin\eslint.cmd
npm ERR! Move it away, and try again.
根据提示手动删除 path D:\testvue\vue2_test\node_modules\.bin\eslint.cmd文件,但重新执行命令时仍然报错提示该目录下的其他文件。
解决办法:cnpm install --save vue-router@3
更多推荐
所有评论(0)