Reputation: 43
I create new file testcomp.vue
in pages/index.vue I add
import testcomp from 'components/testcomp'
in export default{} i add
components:{
'testcomp': testcomp,
},
after this I run npm install --save components/testcomp
in console log I see next
npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t ssh://[email protected]/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
Why it?
Upvotes: 0
Views: 552
Reputation: 1191
<script>
import testcomp from '~/components/testcomp'
export default {
components: {
testcomp
}
}
</script>
Upvotes: 0
Reputation: 376
You are receiving the error because you are treating your newly created component as if it were an npm package.
npm install --save package/name is only needed when you are wanting to install a new remote package. Not for content created on your computer.
On another note, if you're using the default next setup. I think your import does not match the file structure. I think you need import testcomp from '../components/testcomp'
Upvotes: 1