jazzyarchitects / fasttext-node

Node wrapper around FastText Library
MIT License
57 stars 4 forks source link

Package fails on require('fasttext-node'); #5

Closed vladikus10 closed 6 years ago

vladikus10 commented 6 years ago

I've just installed all of the required components and tried to install the fasttext-node npm package and it seems that the installation went fine, as got this in the terminal:

> fasttext-node@1.1.7 postinstall /home/vlad/Node/nlp/node_modules/fasttext-node
> ./install.sh

c++ compiler is installed... Cool...!!!
Git is installed... Cool...!!!
Curl is installed... Cool...!!!
Installing FastText-Node Module
Downloading Fast Text Library
Cloning into 'fastText'...
remote: Counting objects: 2069, done.
remote: Total 2069 (delta 0), reused 0 (delta 0), pack-reused 2069
Receiving objects: 100% (2069/2069), 4.33 MiB | 1.61 MiB/s, done.
Resolving deltas: 100% (1307/1307), done.
Downloaded Fast Text Library.
Building the library
c++ -pthread -std=c++0x -march=native -O3 -funroll-loops -c src/args.cc
c++ -pthread -std=c++0x -march=native -O3 -funroll-loops -c src/dictionary.cc
c++ -pthread -std=c++0x -march=native -O3 -funroll-loops -c src/productquantizer.cc
c++ -pthread -std=c++0x -march=native -O3 -funroll-loops -c src/matrix.cc
c++ -pthread -std=c++0x -march=native -O3 -funroll-loops -c src/qmatrix.cc
c++ -pthread -std=c++0x -march=native -O3 -funroll-loops -c src/vector.cc
c++ -pthread -std=c++0x -march=native -O3 -funroll-loops -c src/model.cc
c++ -pthread -std=c++0x -march=native -O3 -funroll-loops -c src/utils.cc
c++ -pthread -std=c++0x -march=native -O3 -funroll-loops -c src/fasttext.cc
c++ -pthread -std=c++0x -march=native -O3 -funroll-loops args.o dictionary.o productquantizer.o matrix.o qmatrix.o vector.o model.o utils.o fasttext.o src/main.cc -o fasttext
Installed FastText-Node Library

Building node module
./install.sh: line 79: /home/vlad/Node/nlp/node_modules/fasttext-node/node_modules/.bin/grunt: No such file or directory
Finished installing module

However, when I try to use the module by loading it like so: const fs = require('fasttext-node');, I receive the following message:

module.js:549
    throw err;
    ^

Error: Cannot find module '/home/vlad/Node/nlp/node_modules/fasttext-node/dist/lib'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/vlad/Node/nlp/node_modules/fasttext-node/index.js:4:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

Any ideas why this is happening? FYI, I'm using Debian 9.

vladikus10 commented 6 years ago

I just noticed that it shows ./install.sh: line 79: /home/vlad/Node/nlp/node_modules/fasttext-node/node_modules/.bin/grunt: No such file or directory just before finishing the installation, could this be an issue?

jazzyarchitects commented 6 years ago

@vladikus10 probably. But that shouldn't happen as yarn or npm should actually install grunt and build the module. Can you confirm if grunt was installed with npm install or not?

vladikus10 commented 6 years ago

@jazzyarchitects It seems so:

npm list grunt
nlp@1.0.0 /home/vlad/Node/nlp
└─┬ fasttext-node@1.1.7
  └── grunt@1.0.2 
jazzyarchitects commented 6 years ago

Then try doing the following at the project root.

$ ./node_modules/.bin/grunt build

Out of curiosity, You have a grunt folder inside node_modules directory? or is it inside node_modules/fasttext-node/node_modules?

vladikus10 commented 6 years ago

I get this:

./node_modules/.bin/grunt build
A valid Gruntfile could not be found. Please see the getting started guide for
more information on how to configure grunt: http://gruntjs.com/getting-started
Fatal error: Unable to find Gruntfile.

I checked the folders and the grunt module is the project/node_modules folder. The fasttext-node does not have a node_modules folder at all.

jazzyarchitects commented 6 years ago

The this should work:

$ cd node_modules/fasttext-node/ && node ../.bin/grunt build
vladikus10 commented 6 years ago

I ended up with this:

~/Node/nlp$ cd node_modules/fasttext-node/ && node .././bin/grunt build
module.js:549
    throw err;
    ^

Error: Cannot find module '/home/vlad/Node/nlp/node_modules/bin/grunt'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3

SO is the grunt module supposed to be in the .bin folder and not just in the node_modules?

jazzyarchitects commented 6 years ago

First of all the path you passed is wrong. You used .././bin instead of ../.bin

Secondly, I think that yarn or npm directly copies the grunt binaries to .bin directory while installing. Try running yarn or npm again. It should work.

Else I would need more details like

  1. OS
  2. node version
  3. yarn/npm version
vladikus10 commented 6 years ago

Oh, sorry. I fixed the path and now it works. Thanks for the help!

jazzyarchitects commented 6 years ago

Welcome