RangerMauve / webrun

Run Web-first ESM modules outside of the browser
https://webrun-presentation.hashbase.io/
MIT License
76 stars 4 forks source link

env: node\r: No such file or directory #16

Closed Gozala closed 5 years ago

Gozala commented 5 years ago

I get following error on osx:

env: node\r: No such file or directory

I believe it's due to line brakes used in file

RangerMauve commented 5 years ago

Dang it Windows! I'm a little busy today, but you should be able to go in there and do a find and replace for \r in a code editor. (Inside cli-runner.js)

Gozala commented 5 years ago

@RangerMauve I did that already, I'll probably submit pull to fix that as well

RangerMauve commented 5 years ago

That would be awesome. 💜

Gozala commented 5 years ago

I just forked & it does not look like there is an issue with my local fork, I wonder if it's something with a version on npm

RangerMauve commented 5 years ago

Oh! It's due to my git client automagically converting \r when I commit, but NPM isn't able to do that when publishing.

Gozala commented 5 years ago

BTW I also have issue with a forked version:

portal (dev) ../webrun/bin/cli-runner.js --allow-require src/local/main.js
(node:14700) ExperimentalWarning: vm.SourceTextModule is an experimental feature. This feature could change at any time
(node:14700) UnhandledPromiseRejectionWarning: Error: Cannot find module 'web-streams-node'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at require (/Users/gozala/Projects/webrun/src/plugins/node.js:72:14)
    at file:///Users/gozala/Projects/portal/src/local/http.js:1:38
    at SourceTextModule.evaluate (internal/vm/source_text_module.js:228:25)
    at DefaultWebrun.import (/Users/gozala/Projects/webrun/src/Webrun.js:37:20)
(node:14700) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was nothandled with .catch(). (rejection id: 2)
(node:14700) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Gozala commented 5 years ago

I suspect there's something with module resolution algorithm

RangerMauve commented 5 years ago

Would you mind posting the code you're using? It should be importing based on the pwd.

Also, I think I'll need to add this as a pre-publish hook to convert cr to lf.

Gozala commented 5 years ago

It's actually published here is the source for src/local/main.js being passed

RangerMauve commented 5 years ago

You didn't happen to forget to install web-streams-node by any chance did you? 😅

Seems to be throwing on this require call

Gozala commented 5 years ago

You didn't happen to forget to install web-streams-node by any chance did you? 😅

Seems to be throwing on this require call

No I have it. And it does work if I run yarn local which uses npm installed webrun. So I think there's something with starting it as ../webrun/bin/cli-runner.js --allow-require src/local/main.js

RangerMauve commented 5 years ago

Oh wow, I think it's because I'm a dingus.

https://github.com/RangerMauve/webrun/blob/master/src/plugins/node.js#L67

Basically, it uses the require logic relative to where webrun is installed rather than the present working directory. Not 100% sure what to do about that unless there's a module that lets you require relative to an arbitrary path.