Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'regex-trigram' #2

Closed
lgessler opened this issue Dec 29, 2015 · 4 comments
Closed

Cannot find module 'regex-trigram' #2

lgessler opened this issue Dec 29, 2015 · 4 comments

Comments

@lgessler
Copy link

Hi,

First of all thank you for sharing this library with the world--I find myself in need of Russ Cox's algorithm in a JS project and am very happy to find a port of his Go code.

The problem.
This is what I have done to reproduce the bug, both on my personal machine (OSX) and a Digital Ocean Ubuntu 14.04 droplet set up for Node:

mkdir project && cd project
npm init
vim package.json
# add:
# "dependencies": {
#   "regex-trigram": "*",
#   "pegjs": "*"
# },
npm install
echo "var regex = require('regex-trigram');" > index.js
node index.js

This produces an error:

module.js:339
    throw err;
    ^

Error: Cannot find module 'regex-trigram'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/root/tst/index.js:2:13)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)

Attempts at solutions.

  1. Installing globally with npm install -g regex-trigram does not affect the error.

  2. If I change the line to var regex = require('./node_modules/regex-trigram/src/app.js');, I instead get this error:

module.js:339
    throw err;
    ^

Error: Cannot find module '../build/regex-peg'
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/root/tst/node_modules/regex-trigram/src/regex-trigram.js:19:11)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)

Of course, no such directory /.../node_modules/regex-trigram/build exists, so this is expected. I see there is a Gruntfile in the directory for regex-trigram, but I suspect if I need to use grunt then I am going about requiring this package the wrong way.

@bfulton
Copy link
Owner

bfulton commented Dec 29, 2015

@lgessler thanks for reporting — will check it out today.

@lgessler
Copy link
Author

I don't think this is a permanent solution, but I was able to get it working for now by doing the following:

# from the project's directory
cd node_modules/regex-trigram
npm install grunt --save-dev
npm install
grunt
cd ../..
vim index.js
# change require line to 
# var regex = require('./node_modules/regex-trigram/src/regex-trigram.js');
node index.js

@bfulton
Copy link
Owner

bfulton commented Dec 29, 2015

@lgessler good to know the workaround. I have been including from browser only so far, but sounds like it may be straightforward to fix the node case.

@bfulton
Copy link
Owner

bfulton commented Jan 2, 2016

Fixed in 0.0.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants