1

I am creating vue-cli project and everything works file, but when i try to install new module it show me error after install :

This dependency was not found:

* fs in ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/components/Index.vue, ./~/mp3-duration/index.js and 1 other

To install it, you can run: npm install --save fs

I tried multiple times to confirm but still an error, in the node_modules folder there is a library.

I am installing this module and using :

const musicdata = require('musicmetadata');

After add above code i am writing this :

getDuration(file) {
   fs.createReadStream(file), (err, metadata) => {
      if (err) throw  err;
         console.log(metadata)
   }
}

But getting an error as I specified above, I want a single page website but want some node_modules to get some information, how do I include these modules?

Thanks

Reza Mousavi
  • 4,420
  • 5
  • 31
  • 48
Earon
  • 733
  • 1
  • 12
  • 18
  • I guess, the `fs` module is native and part of your node, there is no need to install it explicitly. – David R May 10 '17 at 06:49
  • yes david but i am using vue-cli and i think it doesn't have fs module because vue-cli compile web pages with build command. – Earon May 10 '17 at 07:03

1 Answers1

1

I would say this is because fs is a specifically for reading files in a Node application and you're running it in the browser. You could look into the FileReader API which helps read local files (and I would imagine your application's files). Worst case, someone has written an NPM package for it.

Csmendoza
  • 11
  • 1
  • Welcome to StackOverflow. You could improve your answer by providing more information on why the linked page would solve the problem and how to do it. Also, pointing to a NPM package, if you know any. – Rodrigo Rodrigues Oct 03 '18 at 17:31