cli icon indicating copy to clipboard operation
cli copied to clipboard

--options-path path/to/options.json results in "cannot find module"

Open jonnolen opened this issue 11 years ago • 4 comments

Version info: Sequelize [Node: 0.10.31, CLI: 1.9.1, ORM: 3.9.0]

Tree:

.
├── db
│   ├── config
│   │   └── config.json
│   ├── migrations
│   ├── models
│   │   └── index.js
│   ├── seeders
│   └── sequelize-cli-options.json

sequelize-cli-options.json:

{
  "migrations-path": "db/migrations",
  "models-path": "db/models",
  "seeds-path": "db/seeds",
  "config": "db/config/config.json"
}

command: ./node_modules/.bin/sequelize --options-path "./db/sequelize-cli-options.json" model:create --name "Airplane" --attributes "name:string(256),manufactureDate:date,isActive:boolean"

output:

module.js:340
    throw err;
          ^
Error: Cannot find module './db/sequelize-cli-options.json'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at /Users/jon/src/test_node/node_modules/sequelize-cli/bin/sequelize:27:23
    at Object.<anonymous> (/Users/jon/src/test_node/node_modules/sequelize-cli/bin/sequelize:44:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

jonnolen avatar Oct 09 '15 15:10 jonnolen

looks like the problem is https://github.com/sequelize/cli/blob/master/bin/sequelize#L22

proposing adding:

+  if (optionsPath){
+     optionsPath = path.resolve(process.cwd(), optionsPath);
+ }
  if (!optionsPath && fs.existsSync(rcFile)) {
    optionsPath = rcFile;
  }

jonnolen avatar Oct 09 '15 15:10 jonnolen

should be "seeders-path" not seeds-path :)

ashwinijindal10 avatar Oct 26 '15 03:10 ashwinijindal10

i just figured that out a couple of days go, but the relative path issue was still a problem.

jonnolen avatar Oct 26 '15 14:10 jonnolen

closed by #210

jonnolen avatar Oct 26 '15 14:10 jonnolen