[Vuejs]-Import and use a npm package in VueJs Project

0๐Ÿ‘

Do a npm install first on taffy npm install --production taffy then after that go to the code you want to use it on and require it TAFFY = require( 'taffy' ).taffy; in the documentation it says require it try it that way instead of doing import from.

Check the documents to https://www.npmjs.com/package/taffydb#use-it-in-nodejs

and
http://taffydb.com/

I hope this helps you out !

0๐Ÿ‘

I have the same problem. I will resolve doing this:

  1. Download taffy-min.js on official page

  2. Move this file to /plugin folder on your project

  3. In the file .vue that you need use. Copy this line on script section

    import { taffy } from โ€˜@/plugins/taffy-min.jsโ€™;

  4. And on mounted()methods you can write:

    const friends = taffy([ {"id":1,"gender":"M","first":"John","last":"Smith","city":"Seattle, WA","status":"Active"}, {"id":2,"gender":"F","first":"Kelly","last":"Ruth","city":"Dallas, TX","status":"Active"},
    {"id":3,"gender":"M","first":"Jeff","last":"Stevenson","city":"Washington, D.C.","status":"Active"},
    {"id":4,"gender":"F","first":"Jennifer","last":"Gill","city":"Seattle, WA","status":"Active"}
    ]);

More: if you are using Typerscript, dont forget write "declare module โ€˜@/plugins/taffy-min.jsโ€™;" on "delcarations.d.ts" on src folder to work.

I hope work for you! Sorry for my english! ๐Ÿ™‚

Leave a comment