Added step-by-step instructions to 'how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package/index.md' (#35868)

* Added step-by-step instructions and screenshots

Added step-by-step instructions to set up an anonymous node/express project for the challenges and three demo screenshots.

* Removed screenshots from instructions

* fix: changed javascript to json

* fix: changed to two-space indentation
This commit is contained in:
Ina S.Lew
2019-06-25 22:15:51 +02:00
committed by Randell Dawson
parent 7659d1fdaa
commit 566e112d5d

View File

@ -3,14 +3,46 @@ title: How to Use package.json, the Core of Any Node.js Project or npm Package
---
## How to Use package.json, the Core of Any Node.js Project or npm Package
This is a simple exercise, you should be able to complete it by following the steps listed in the exercise itself.
According to [this issue discussed on freeCodeCamp's git repo](https://github.com/freeCodeCamp/freeCodeCamp/issues/34798), the bootstrapped glitch project in the [introduction](https://learn.freecodecamp.org/apis-and-microservices/managing-packages-with-npm/) will NOT work if you're not logged in on glitch.
CAUTION:
Here's how to set up a new node/express project anonymously:
Note that there is an issue with Glitch, where the link that clones the specific FreeCodeCamp app on Glitch may not actually clone the app and instead give you the default Glitch app. The README.MD file should say "Backend Challenges boilerplate - package.json", if it doesn't, you don't have the FreeCodeCamp version of the app and your tests will not pass. The solution is to try until you actually get the the proper app imported.
1. In the glitch project you opened from the introduction page, go to the top left corner for "project options" and click on "New Project".
You should go over to the `package.json` file in your project. As mentioned in the instructional section of the lesson, JSON is written in key pairs like this:
2. Click on "hello-express" to start a new node/express project
```json
"author": "Jane Doe",
```
3. We're not done yet; go to `server.js` on __YOUR glitch project__, and replace everything in there with this `server.js` on [freeCodeCamo's repo](https://github.com/freeCodeCamp/boilerplate-npm/blob/gomix/server.js)
4. Then, go to `package.json` on __YOUR glitch project__, and again, replace everything in thEre with the `package.json` on [freeCodeCamp's repo](https://github.com/freeCodeCamp/boilerplate-npm/blob/gomix/package.json)
5. Finally, to submit your solution, go to "Share", click on the "App" tab and copy the link to your app. Submit this link when your solution is ready.
Now, you're ready to solve the challenges :sparkles:
Remember, you're writing JSON, so make sure you use
1. double quotes
2. `"key": value` format
3. the correct number of commas
SPOILER ALERT. DO NOT SCROLL DOWN IF YOU WISH TO KEEP TRYING
```json
{
"name": "fcc-learn-npm-package-json",
"author": "foobar",
"dependencies": {
"express": "^4.14.0"
},
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"engines": {
"node": "8.11.2"
},
"repository": {
"type": "git",
"url": "https://idontknow/todo.git"
}
}
```