0

Is it possible to use a component without having npm?

I'm trying to make https://www.npmjs.com/package/vue-bootstrap4-table#4-basic-usage work but it fails.

I can't import component inside html file.

Tried:

import VueBootstrap4Table from 'vue-bootstrap4-table';

app = new Vue({
  el: '#app',
  data: {
    rows: [{

Here is the fiddle.

What is wrong with this code?

2
  • 1
    import VueBootstrap4Table from 'vue-bootstrap4-table'; a) you need webpack (or another bundler) to resolve the import, b) webpack will try to resolve the import from the node_modules folder (which you won't have without npm). Just use npm. It's the way to go. Any attempt on using any modern packages or frameworks without npm is bound to fail. Commented Oct 18, 2019 at 19:51
  • 1
    @connexo Actually modern browsers can handle those import statements if they're inside a module and not a JS import. The path has to be a valid URL, standard URL rules apply (absolute, relative, etc...), the file extension should be .mjs, and you can use a tool like unpkg.me to get a URL to what is normally a node package. I'm not saying I'd recommend this for a production project but the question doesn't sound like it's asking about production code. Commented Oct 18, 2019 at 20:39

1 Answer 1

2

remove:

import VueBootstrap4Table from 'vue-bootstrap4-table';

and

...,
components: {
  VueBootstrap4Table
}

from the bottom of your Vue instance - by adding the CDN reference, it's already included.

Then lastly, looks like you were missing the bootstrap css for this table. I added it as a dependency in the fiddle.

check it out:

https://jsfiddle.net/u4twL905/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.