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 #20

Closed
themre opened this issue Apr 27, 2017 · 15 comments
Closed

Cannot find module #20

themre opened this issue Apr 27, 2017 · 15 comments

Comments

@themre
Copy link

themre commented Apr 27, 2017

hi,
I did a fresh install of idyll and yo. Ran yo idyll and npm start and got:

Spellcheck:
var: did you mean vary
Error: Cannot find module 'c:\git\demo-idyll\c' from 'c:\git\demo-idyll'

anyone else got this problem?

@rreusser
Copy link
Member

I wonder if maybe it's a windows path issue. To rule out the content and if it's not too long, can you post the .idl file? I've experienced it where syntax errors or other issues on my end cause messages that weren't necessarily what I needed to know to debug it.

@themre
Copy link
Author

themre commented Apr 27, 2017

index.idl? I haven't changed it one bit. however when I open components.js, I see different slashes:

module.exports = {
"header": require('c:\git\demo-idyll\components\default/header'),
"range": require('c:\git\demo-idyll\components\default/range'),
"display-var": require('c:\git\demo-idyll\components\default/display-var'),
"custom-component": require('c:\git\demo-idyll\components/custom-component')
} 

perhaps this is the issue. I'll try with different slahes.

@themre
Copy link
Author

themre commented Apr 27, 2017

nope, doesn't help, because it's generated one I run app. here is index.idl content:

[meta title:"Page Title" description:"Short description of your project" /]

[Header
  title:"Welcome to Idyll"
  subtitle:"Open index.idl to start writing"
  author:"Your Name Here"
  authorLink:"https://idyll-lang.github.io" /]


This is an Idyll file. Write text
as you please in here. To add interactivity,
you can add  different components to the text.

Here is how you can use a variable:

[var name:"exampleVar" value:5 /]

[Range min:0 max:10 value:exampleVar /]
[DisplayVar var:exampleVar /]

var code = true;


And here is a custom component:

[CustomComponent /]

You can use standard html tags if a
component with the same name
doesn't exist.

@rreusser
Copy link
Member

rreusser commented Apr 27, 2017

Ah, apologies. It's become a knee-jerk reflex to ask for full input before debugging output, but I think the issue is here. Specifically that it creates paths by adding a '/' instead of the platform-agnostic path.join. There might be another one or two hiding in that file, but I think it should be a simple fix.

@themre
Copy link
Author

themre commented Apr 27, 2017

any way to help debug this?

@mathisonian
Copy link
Member

Thanks @rreusser, I'm guessing that's what it is.

@themre I'll push a fix for the slashes today, but I don't have a windows machine to easily test on if you could take a look after that

@themre
Copy link
Author

themre commented Apr 27, 2017

great. let me know and i'll test!

@rreusser
Copy link
Member

rreusser commented Apr 27, 2017

See #20. I pushed… well, not so much a fix because I don't have a windows machine either, but it's at least a shot in the dark at replacing string-based path construction with path operations. Let me know if you think it's a good/bad move, @mathisonian.

@themre you might be able to clone, check out the branch, npm install and run node bin/idyll.js manually in the source directory in order to test, but maybe there's a better way to check this. Or maybe just better to wait and see if this is acceptable and/or fixes it. Not sure. 🤷‍♂️

@themre
Copy link
Author

themre commented Apr 27, 2017

tried, got this error:

fs.js:951
  return binding.readdir(pathModule._makeLong(path), options.encoding);
                 ^
Error: ENOENT: no such file or directory, scandir 'c:\git\idyll\components\default'
    at Error (native)
    at Object.fs.readdirSync (fs.js:951:18)
    at idyll (c:\git\idyll\src\index.js:63:25)

@rreusser
Copy link
Member

Thanks for testing! Hopefully that's progress. The line it points to is this:

const components = fs.readdirSync(DEFAULT_COMPONENTS_FOLDER);

I wonder if that needs to be something really explicit like path.join(process.cwd(), DEFAULT_COMPONENTS_FOLDER).

@themre
Copy link
Author

themre commented Apr 27, 2017

like const components = path.join(process.cwd(), DEFAULT_COMPONENTS_FOLDER); ?
if so, I get:

{ Error: ENOENT: no such file or directory, scandir 'c:\git\idyll\components'
    at Error (native)
    at Object.fs.readdirSync (fs.js:951:18)
    at idyll (c:\git\idyll\src\index.js:66:27)
    at Object.<anonymous> (c:\git\idyll\bin\idyll.js:38:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'c:\\git\\idyll\\components' }
fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

TypeError: path must be a string or Buffer
    at TypeError (native)

@mathisonian
Copy link
Member

Yeah, I don't think 'c:\git\idyll\components\default' is really the path we want to be scanning here. For some reason the logic constructing that isn't working correctly (maybe something with this?)

If it isn't obvious how to fix it, UW has some windows machines I can test on later today.

@rreusser
Copy link
Member

Sorry, I meant

const components = fs.readdirSync(path.join(process.cwd(), DEFAULT_COMPONENTS_FOLDER));

but I think it might require a closer look at the relative requires. path.join strips out leading '.' so that you have to be a bit more careful. I think it probably needs __dirname or process.cwd() in the right places, depending on whether it's relative to the idyll src directory or your project src directory.

@mathisonian
Copy link
Member

I just merged #21, added automated testing in a windows environment, and released a patch on npm (v1.1.2).

@themre let me know if you still have problems after this patch. To update either run npm install idyll@1.1.2 inside of your idyll project folder, or create a new folder using the project generator.

@themre
Copy link
Author

themre commented Apr 30, 2017

It works!
I had to upgrade also default-components:

"idyll": "~1.1.3",
"idyll-default-components": "^1.0.3"

Many thanks!

@themre themre closed this as completed Apr 30, 2017
bclinkinbeard pushed a commit that referenced this issue Aug 10, 2017
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

3 participants