我创建了新文件testcomp.vue
在pages/index.vue中我添加了
import testcomp from 'components/testcomp'
在导出默认{}中我添加了
components:{
'testcomp': testcomp,
},
之后,我运行testcomp npm install --保存组件/
在控制台日志中,我将看到以下内容
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
为什么会这样呢?
发布于 2018-06-03 03:48:48
您之所以收到这个错误,是因为您将新创建的组件视为npm包。
npm install --仅当您想要安装新的远程包时,才需要保存包/名称。不适用于在您的计算机上创建的内容。
另外,如果您使用的是默认的next设置。我认为您的导入与文件结构不匹配。我认为您需要从'../components/ testcomp‘导入testcomp
发布于 2018-06-03 14:09:43
<script>
import testcomp from '~/components/testcomp'
export default {
components: {
testcomp
}
}
</script>
https://stackoverflow.com/questions/50659830
复制相似问题