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

Make models_index.js invokable from any directory #29

Open
asishallab opened this issue Apr 22, 2020 · 1 comment
Open

Make models_index.js invokable from any directory #29

asishallab opened this issue Apr 22, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@asishallab
Copy link
Member

When opening a interactive node shell not inside the root directory of graphql-server and requiring e.g.

var m = require('./graphql-server/models_index.js')

You get an error

Uncaught Error: ENOENT: no such file or directory, scandir './models'                                                                                                                                              
    at Object.readdirSync (fs.js:872:3)                                                                                                                                                                            
    at Object.<anonymous> (/home/cons/EMPHASIS-Layer/cenzontle_git_projects/Sandbox_real/SIAGRO/instance_3_gef/graphql-server/models_index.js:13:4)                                                                
    at Module._compile (internal/modules/cjs/loader.js:1156:30)                                                                                                                                                    
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18) {
  errno: -2,
  syscall: 'scandir',
  code: 'ENOENT',
  path: './models'
}

Fix this by using path specifications that work always independently of from where models_index.js is required.

Look at __dirname and path.

@asishallab asishallab added the bug Something isn't working label Apr 22, 2020
@tmvoe
Copy link

tmvoe commented Apr 22, 2020

The fix is now committed on the graphql-server.
Branch: issue29-invokable-models-index
Commit: e071fa1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants