signalkuppe / eleventy-react

Use React components in Eleventy.
MIT License
83 stars 15 forks source link

npm run dev doesn't work? (Windows) #1

Open kuworking opened 3 years ago

kuworking commented 3 years ago

Trying to clone and run the repo in a Windows environment, and changing the scripts with cross-env (yarn add -D cross-env)

    "dev": "cross-env ELEVENTY_EXPERIMENTAL=true eleventy --serve",
    "build": "cross-env ELEVENTY_EXPERIMENTAL=true eleventy",

Then with npm run dev it just doesn't work, no error messages, simply the terminal ends the process instead of being alive

PS C:\...\eleventy-react> npm run dev

> eleventy-react@0.2.2 dev C:\...\eleventy-react
> cross-env ELEVENTY_EXPERIMENTAL=true eleventy --serve

Warning: Configuration API `addExtension` is an experimental Eleventy feature with an unstable API. Be careful!
PS C:\...\eleventy-react> 

EDIT: Also build doesn't seem to do anything

signalkuppe commented 3 years ago

Hi @kuworking have you tried using env ELEVENTY_EXPERIMENTAL=true npx eleventy --serve ?

kuworking commented 3 years ago
'env' is not recognized as an internal or external command,

If I try

"set ELEVENTY_EXPERIMENTAL=true && npx eleventy --serve"
(or)
"set ELEVENTY_EXPERIMENTAL=true & npx eleventy --serve"

Then the same outcome, exiting without any error message

kuworking commented 3 years ago

I have managed to install Ubuntu with Windows-WSL2, and there I've cloned and run your repo and it works as expected

I doubt it has anything to do with your code, but with 11ty (and likely the ELEVENTY_EXPERIMENTAL feature)

OOT: So in this repo you're using React and Styled-Components that are compiled into plain html, vanilla js and vanilla css without any react runntime or similar, right?

signalkuppe commented 3 years ago

I have managed to install Ubuntu with Windows-WSL2, and there I've cloned and run your repo and it works as expected

I doubt it has anything to do with your code, but with 11ty (and likely the ELEVENTY_EXPERIMENTAL feature)

Ok, thanks for finding this.

OOT: So in this repo you're using React and Styled-Components that are compiled into plain html, vanilla js and vanilla css without any react runntime or similar, right?

Yeah, the output it's just plain html and css, client-side js is up to you.

kuworking commented 3 years ago

It's awesome, I just wanted to say thanks for the repo :)

Feel free to close the issue, or I can close it when the 11ty one is fixed

dvelasquez commented 3 years ago

@kuworking You can install cross-env and modify your dev script to this: "dev": "cross-env NODE_ENV=dev npm-run-all clean build:ts -p watch:* -- --watch",

I switch a lot between windows, linux and osx, and this is very useful for this kind of cases ;)

kuworking commented 3 years ago

@kuworking You can install cross-env and modify your dev script to this: "dev": "cross-env NODE_ENV=dev npm-run-all clean build:ts -p watch:* -- --watch",

I switch a lot between windows, linux and osx, and this is very useful for this kind of cases ;)

I tried with cross-env without success, but if in your hands it works then I'm very interested

If possible, could you provide a script that works with this repo? in the sense that here there's no build:ts or watch

If I run a stripped down version "dev": "cross-env NODE_ENV=dev npm-run-all build -p", it again exists without any error message

striberny commented 3 years ago

in react/findSources.js (line 6) there might by some path issues when using path.join method in Windows (the determined path has backslashes causing the fastglob function to return an empty array).

You could try replacing

let globPath = path.join(dir, '**/*.jsx');

with

let globPath = path.posix.join(dir, '**/*.jsx');

kuworking commented 3 years ago

in react/findSources.js (line 6) there might by some path issues when using path.join method in Windows (the determined path has backslashes causing the fastglob function to return an empty array).

You could try replacing

let globPath = path.join(dir, '**/*.jsx');

with

let globPath = path.posix.join(dir, '**/*.jsx');

I need to find some time to go deeper here (some errors here and there), but just using this posix line seems to me that this actually does the trick (!)

I'd say I can now run the code in Windows as in WSL (I'll confirm as soon as I can), thanks!