MostlyAdequate / mostly-adequate-guide

Mostly adequate guide to FP (in javascript)
Other
23.39k stars 1.86k forks source link

help needed to run the exercises, ideally in VS Code #621

Closed mals14 closed 3 years ago

mals14 commented 3 years ago

I followed the instructions to setup a Mac to run the exercises.

clone the repository (git clone git@github.com:MostlyAdequate/mostly-adequate-guide.git)
go in the exercises section (cd mostly-adequate-guide/exercises)
install the necessary plumbing using npm (npm install)

Then I opened the folder "mostly-adequate-guide" in VS Code.

cd mostly-adequate-guide
code .

From inside VS Code, opened exercises/ch04/exercises_a.js Then modified the file to be

const words = str => split(' ', str);
console.log(words('hello there'));

Now I am not able to run this file from the terminal inside of VS Code. Error as below. Node version installed is v16.0.0.

node exercises/ch04/exercise_a.js                                                                                     Thu Jun 24 09:25:26 2021
~/mostly-adequate-guide/exercises/ch04/exercise_a.js:4
const words = str => split(' ', str);
                     ^
ReferenceError: split is not defined

Neither am I able to run this program using VS Code "Run and Debug" which is what I would ideally like to do. The launch.json file in VS Code is as follows

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}/exercises/ch04/exercise_a.js"
        }
    ]
}

Thank you for reading.

klequis commented 3 years ago

I don't know how to solve your issue but if you haven't solved it yet ... I have used an alternative approach. I have a repo where I paste the code examples and play with it. It doesn't run tests on exercises but I'm getting far more learning from playing with the code exercises. here is the repo I'm using

davidnussio commented 3 years ago

I'm using the command line npx terminal-playgroung to run js/ts code on the fly

mals14 commented 3 years ago

I'm using the command line npx terminal-playgroung to run js/ts code on the fly

@davidnussio thank you for replying! I will read about npx and how it is used.

And thanks @klequis - will look at your repository as well.