git - 组件未安装在 nuxt.js 中
问题描述
我创建新文件 testcomp.vue
在 pages/index.vue 我添加
import testcomp from 'components/testcomp'
在导出默认{}中我添加
components:{
'testcomp': testcomp,
},
在此之后我运行npm install --save components/testcomp
在控制台日志中我看到下一个
npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t ssh://git@github.com/components/testcomp.git
npm ERR!
npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Nil\AppData\Roaming\npm-cache\_logs\2018-06-02T17_38_50_009Z-debug.log
为什么呢?
解决方案
您收到错误是因为您将新创建的组件视为一个 npm 包。
npm install --save package/name 仅在您想要安装新的远程包时才需要。不适用于在您的计算机上创建的内容。
另一方面,如果您使用默认的下一个设置。我认为您的导入与文件结构不匹配。我认为您需要从 '../components/testcomp' 导入 testcomp
推荐阅读
- devexpress - 如何在 Devexpress 报表设计器 UI 中添加客户下拉菜单
- python - 按最低价格和最高价格过滤和排序对象
- c++ - 使用 inFile 将文件输入到堆中
- c# - 为什么在 C# 中使用 Dispose() 时出现错误
- c# - FirstOrDefaultAsync 与 FirstOrDefault
- reactjs - form.reset 具有新的初始值,不启用 react-final-form 中的 onSubmit 按钮
- javascript - 以角度反应形式绑定表单数组值
- javascript - 我的 Node 和 express 应用程序在错误处理中间件时没有收到 req.session?
- javascript - 如何在 React 中实现文本转语音
- phpunit - Laravel 测试 - 该名称已被使用