marko-js / marko

A declarative, HTML-based language that makes building web apps fun
https://markojs.com/
MIT License
13.28k stars 641 forks source link

npm run dev fails on windows, default template #1666

Closed Sebring closed 3 years ago

Sebring commented 3 years ago

Marko Version: 5.1.10 (Windows 10)

npm ls marko +-- @marko/build@4.1.1 -- marko@5.1.18 deduped -- marko@5.1.18

Details

Followed the install instructions at https://markojs.com/docs/installing/ using npx @marko/create and not specifying template. default template: default starter app

Expected Behavior

npm run dev is expected to start dev-server

Actual Behavior

npm run dev failed.

The path \<..>\ is edited in this post and should not be considered failing part.

Possible Fix

posix.join? check /vs \

Additional Info ### Your Environment - Node v14.15.4 - Windows 10 - npm 6.14.10 ### Steps to Reproduce 1. $mkdir test %% cd test 2. $npx @marko/create 3. name test, use default template 4. $cd test 5. $npm run dev ### Stack Trace ``` $ npm run dev > test@1.0.0 dev C:\Users\<..>\marko5\test > marko-serve ./src/pages You can now view src\pages in your browser Local Address: http://localhost:3000 On Your Network: http://:3000 Note that marko serve is only intended for development You can create a production-ready build using marko build C:\Users\<..>\marko5\test\node_modules\webpack\lib\util\fs.js:166 throw new Error( ^ Error: . is neither a posix nor a windows path, and there is no 'join' method defined in the file system at join (C:\Users\<..>\marko5\test\node_modules\webpack\lib\util\fs.js:166:9) at C:\Users\<..>\marko5\test\node_modules\webpack\lib\ContextModuleFactory.js:309:27 at arrayEachIndex (C:\Users\<..>\marko5\test\node_modules\neo-async\async.js:2548:9) at Object.map (C:\Users\<..>\marko5\test\node_modules\neo-async\async.js:2900:9) at Array. (C:\Users\<..>\marko5\test\node_modules\webpack\lib\ContextModuleFactory.js:306:14) at runCallbacks (C:\Users\<..>\marko5\test\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:27:15) at C:\Users\<..>\marko5\test\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:200:4 at go$readdir$cb (C:\Users\<..>\marko5\test\node_modules\graceful-fs\graceful-fs.js:214:14) at FSReqCallback.oncomplete (fs.js:171:23) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! test@1.0.0 dev: `marko-serve ./src/pages` npm ERR! Exit status 1 ```
Sebring commented 3 years ago

This is acutally webpack/lib/util/fs.js not handling windows paths properly.

https://github.com/webpack/webpack/issues/12305

Sebring commented 3 years ago

Closing, bug is not in Marko.

giovannipds commented 3 years ago

@Sebring nice, but how did you solve it?

Sebring commented 3 years ago

@Sebring nice, but how did you solve it?

For my private project I just removed the if-statements for the linux parts and made it always assert windows paths with no checking. This would however fail on a linux server in production, keep that in mind.

Maybe this is of interest https://github.com/webpack/webpack/commit/e28788a4d4cacb30d576d2fefede84526709e11f but I haven't tried it myself.

giovannipds commented 3 years ago

@Sebring thank you very much for replying. I tried the PR mentioned (it's already merged) but it didn't solve it. I also tried installing latest webpack, upgrading, downgrading, both marko and/or webpack and just different errors appeared. I'll try what you've mentioned. If you have any more tips, please, let me know.

giovannipds commented 3 years ago

Well... I could

return `${rootPath}/${filename}`;` // DON'T do this

and it run, but this is definitely an open issue.