首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >组件未安装在nuxt.js中

组件未安装在nuxt.js中
EN

Stack Overflow用户
提问于 2018-06-03 02:14:23
回答 2查看 380关注 0票数 0

我创建了新文件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

为什么会这样呢?

EN

回答 2

Stack Overflow用户

发布于 2018-06-03 03:48:48

您之所以收到这个错误,是因为您将新创建的组件视为npm包。

npm install --仅当您想要安装新的远程包时,才需要保存包/名称。不适用于在您的计算机上创建的内容。

另外,如果您使用的是默认的next设置。我认为您的导入与文件结构不匹配。我认为您需要从'../components/ testcomp‘导入testcomp

票数 1
EN

Stack Overflow用户

发布于 2018-06-03 14:09:43

<script>
import testcomp from '~/components/testcomp'

export default {
    components: {
        testcomp
    }
}
</script>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50659830

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档