afloyd / mongo-migrate

MIT License
159 stars 81 forks source link

node can not find mongo-migrate after installing #6

Closed wakandan closed 10 years ago

wakandan commented 10 years ago

My node doesn't seem to be able to find your module for some reason. I followed the steps in README but doesn't work

npm install mongo-migrate node mongo-migrate --> Error: Cannot find module

afloyd commented 10 years ago

It doesn't install globally this way... You need to specify the path to the mongo-migrate directory when running it.

For example:

//This will install it to [currentDirectory]\node_modules\mongo-migrate
npm install mongo-migrate

Then to run it from that same directory you installed it from you would put:

node ./node_modules/mongo-migrate -runmm
imjakechapman commented 9 years ago

Just spent 30 minutes trying to figure out why I wasn't able to create a migration. Plus your README.md doesn't state any of this. Shouldn't node mongo-migrate automatically be looking for the mongo-migrate module from within the ./node_modules folder?

Anyway to add some functionality of being able to automatically search for the ./node_modules folder and maybe a command to automatically set some config options instead of having to put -c ../some/other/directory where migrations will be at, which typically would be in ./app/migrations??

luckydev commented 9 years ago

+1.

crazy! why doesnt node pickup mongo-migrate automatically form ./node_modules directory ?

afloyd commented 9 years ago

Not sure why it doesn't automatically pick it up from within the node_modules folder... I'm not actively using this module anymore, but if you'd like to look into it and issue a pull request with a fix I'd be happy to merge it in and re-publish to npm

jmar777 commented 9 years ago

Node only checks the node_modules folder when you're require()ing a file. It doesn't have any special logic like that when you're passing a script to the node binary itself, though (other than letting the .js extension be optional). The need to specify the path to the script probably just needs to be documented somewhere.

afloyd commented 9 years ago

Good call @jmar777! :+1: I guess when I wrote the readme I just assumed that was a given... lol

luckydev commented 9 years ago

Cant we use preferGlobal option in mongo-migrate's package.json?

mongo-migrate will ideally be used as a command line tool. So giving that option in package.json will make npm install command it globally in the system. Checkout the docs - https://www.npmjs.org/doc/files/package.json.html

Express, for example, if we want to use its command line tool express-generator, the library recommends us to install globally like npm install -g so that the command becomes available in system PATH. We can recommend that in the README.