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

require() is not working for local scripts #90

Open
sh-dave opened this issue Nov 30, 2016 · 2 comments
Open

require() is not working for local scripts #90

sh-dave opened this issue Nov 30, 2016 · 2 comments

Comments

@sh-dave
Copy link
Contributor

sh-dave commented Nov 30, 2016

Currently it's not possible to require local scripts from within khafile.js.

khafile.js

const myscript = require('./myscript.js');
let project = new Project('xxx');
...
Creating Kha project.
{ Error: Cannot find module './myscript.js'
...

I guess this is due to how the projectfile is run in https://github.com/KTXSoftware/khamake/blob/master/src/ProjectFile.ts#L24
as it only gets very limited access to anything from the executing script.

@RobDangerous
Copy link
Member

I guess it's because the current script dir is something else when the code executes. But should be possible to fix that...

@sh-dave
Copy link
Contributor Author

sh-dave commented Dec 8, 2016

Found a workaround for now: just create a node_modules folder in your project root drop myscript.js there and then you can require('myscript.js') in khafile.js and it gets picked up.

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