Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First reference to package.json needs an explanation #7

Open
juananpe opened this issue Sep 23, 2022 · 5 comments
Open

First reference to package.json needs an explanation #7

juananpe opened this issue Sep 23, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@juananpe
Copy link
Contributor

I think that this reference to package.json should be clarified
https://github.com/gvwilson/sdxjs/blame/main/en/src/systems-programming/index.md#L76
(as far as I can tell, this is the first reference to that file, isn't it?)

@zkamvar
Copy link

zkamvar commented Jun 8, 2023

Hi @juananpe, I'm curious why this was closed. This still seems to be the first mention of package.json.

I'm currently going through the book right now and I'm finding that this missing bit of setup information is causing me to get "SyntaxError: Cannot use import statement outside a module" errors because I don't have a package.json file.

@juananpe
Copy link
Contributor Author

juananpe commented Jun 9, 2023

Hi @zkamvar, you are right. Let's open it again so @gvwilson can have a look at it.

@juananpe juananpe reopened this Jun 9, 2023
@zkamvar
Copy link

zkamvar commented Jun 12, 2023

I think what's missing is setup instructions and a disambiguation between node and npm (a la rustc and cargo in the rust book).

@bouzlibop
Copy link

bouzlibop commented Feb 19, 2024

In "Chapter 1: Introduction" in "Section 1.1: Who is our audience?" we can read that:

Like these three personas, readers should be able to:
[...]
• Install Node on their computer and run programs with it from the command line.

I guess it is assumed that the reader have a basic understanding of Node, npm and hence package.json. Maybe it would be worth at least to link to the documentation though.

@zkamvar
Copy link

zkamvar commented Feb 28, 2024

I guess it is assumed that the reader have a basic understanding of Node, npm and hence package.json. Maybe it would be worth at least to link to the documentation though.

Yes, but what do you mean by a 'basic understanding' in this context? I would consider myself to have a basic understanding according to the criteria listed in the "Audience" section, but I did not stumble because of any lack of knowledge of what a package.json is.

I stumbled because of a variety of reasons: While I have worked with Node in the past, I did not have a clear disambiguation between JavaScript and Node. Any time I worked with Node, it was always through npm, but the resources that clearly disambiguate the two are not easily found, so my concept map was incomplete. Beyond that, the first thing we are presented with in the book is a single JS file and then a command to run that file from the command line. The unstated assumption is that we are working inside of a Node package, which requires either a hand-crafted or npm init'd packages.json file. I say this is an unstated assumption because it is very possible to write a stand-alone JS file to work by running node my-file.js outside of a package context (and is not at all uncommon in other programming languages).

My suggestion would be to 1) add something to the requirements that indicates to the user that they should know the differences between JavaScript and Node JavaScript and 2) clearly indicate that we are in a package context for the examples (my inserted text is in bold and the additional callout):

To start, let’s try creating a new module for listing the contents of a directory the way we would in Python or Java:

Examples in this book

All examples in this book are created within a Node package or module
context created with npm init.

@gvwilson gvwilson self-assigned this Feb 28, 2024
@gvwilson gvwilson added the bug Something isn't working label Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants