cyclejs-community / one-fits-all

The one-fits-all flavor for create-cycle-app
MIT License
34 stars 8 forks source link

Can't start a script when flavor is linked locally on Windows #5

Closed jvanbruegge closed 7 years ago

jvanbruegge commented 7 years ago

From @SteveALee on July 31, 2017 12:40

I'm using the local flavor option ie

create-cycle-app cspa-test --flavor ./create-cycle-app-flavors\packages\cycle-scripts-one-fits-all

Everything works until you try npm start etc. which fails with The system cannot find the path specified.

This boils down to node's child_process.execFileSync being called with something like

command: C:\WINDOWS\system32\cmd.exe

args: ['/s' ,'/c','""C:\projects\create-cycle-app-flavors\packages\.bin\webpack-dev-server" "--config" "C:\projects\create-cycle-app-flavors\packages\cycle-scripts-one-fits-all\configs\webpack.config.js""'

options: { env: { NODE_ENV: 'development' }, stdio: 'inherit', windowsVerbatimArguments: true }

I'm not sure why it's trying to tun the webserver in "C:\projects\create-cycle-app-flavors\packages\.bin which is invalid.

Copied from original issue: cyclejs-community/create-cycle-app-flavors#42

jvanbruegge commented 7 years ago

From @SteveALee on July 31, 2017 13:45

https://github.com/cyclejs-community/create-cycle-app-flavors/blob/master/packages/cycle-scripts-one-fits-all/scripts/start.js#L8

../.. is incorrect when the package is linked in from create-cycle-app using a local flavor!

Perhaps detect is local flavor and then only .. assuming flavor has been manually installed

jvanbruegge commented 7 years ago

From @SteveALee on August 2, 2017 8:8

As we are looking for the script in node_modules is there an API to get that rather than assuming relative path? Need to be the top one in the using package though in case there's another child one

jvanbruegge commented 7 years ago

The path is not the main problem. npm v5 changed something(TM) and not this is not working for me either

jvanbruegge commented 7 years ago

From @SteveALee on August 2, 2017 8:9

ah

jvanbruegge commented 7 years ago

the script should be symlinked in node_modules/.bin by npm itself, but it seems like it's not doing that for symlinked packages I have to investigate that and maybe open a bug report

jvanbruegge commented 7 years ago

From @SteveALee on August 2, 2017 8:11

Problem is the .bin is not in ../.. when flavor linked from app node_modules. That's the 1st problem I found. Is it the minimall flat package layout that broke it? Or was that earlier npm?

jvanbruegge commented 7 years ago

A solution might be to change the scripts to use

path.join(process.cwd(), 'node_modules', '.bin')

But then again, the binaries are not properly symlinked by npm Maybe require.resolve can help

jvanbruegge commented 7 years ago

From @SteveALee on August 2, 2017 8:19

hmm - probably OK, unless script launched from other directory - but seems very unlikely as we always cd project 1st

jvanbruegge commented 7 years ago

From @SteveALee on August 2, 2017 8:23

But then again, the binaries are not properly symlinked by npm

should they be? Surely only the flavor package folder gets linked and package.json updated to match with a 'file://' ?

Are you running scripts defined by the flavour. Then yes I see what you are saying. hmmm.

jvanbruegge commented 7 years ago

This is will be fixed with the next release of create-cycle-app by using yarn (npm v5 is buggy).

create-cycle-app myApp --flavor cycle-scripts-one-fits-all --yarn

https://github.com/cyclejs-community/create-cycle-app/issues/115