Current updates in Free Code Camp

Free Code Camp has been a great help. And also a source of great frustration. Just like every other tutorial out there, it is affected by the rapid, constant changes in the JS Landscape.

The frustration comes when it seems impossible to get through a lesson with code that has been deprecated, obsoleted, or just doesn’t work.

One tip: Don’t add any extra ‘fluff’ to a course. The fewer things to break, the more likely your lesson will still be valid a month later.

Second tip: maybe set up an app that monitors all the FCC code in lessons and email the authors when there’s an error response. There’s a lot of material here, and it would be impossible to keep it all up to date without some automation and efficient use of contributors time.

Third: Create a script or Docker for a common, stable environment where everything works and where actual learning can occur. I’ve been trying to learn JS for a while, and every tutorial is different, introduces new bugs, creates another search of StackOverflow for 3 different solutions, all with other different packages that may or may not work, leading down 6 different rabbit holes of somebody elses code trying to get it to work.

Four: Put a date, setup, and version numbers on your tutorial. Overall, it seems the entire JS environment is in flux and nearly impossible to find tutorials that still work.

The Beta curriculum is indeed in flux, however the content should all work. And the curriculum does have integration testing. It would help if you could provide specific examples of lessons you believe have bugs so they can be verified and triaged.

How to Set up a server for Your CRUD Restful API with Node.js and Express

Step #1

import express from 'express';

import express from ‘express’;
^^^^^^
SyntaxError: Cannot use import statement outside a module

Which challenge is this?

URL: How to Create a CRUD API – NodeJS and Express Project for Beginners

Just to confirm, did you do this step?

After installing Express, go to the package.json file and include “type”: “module” . This declaration will tell Node that this project will be using ES6 module syntax (import/export) instead of common.js, which is the default in Node.

Another:

// Getting the list of users from the mock database
router.get('/', (req, res) => {
    res.send(users);    <<---------------------------------
})

export default router

What is this ‘users’ refering to? users.js, users.object, or users.endpoint? no idea.

I’ll add that. package.json didn’t have ‘module’.
{
“name”: “backend”,
“version”: “1.0.0”,
“main”: “index.js”,
“scripts”: {
“test”: “echo "Error: no test specified" && exit 1”,
“dev”: “server.js”,
“start”: “node server.js”
},
“keywords”: ,
“author”: “RivetRivet”,
“license”: “ISC”,
“description”: “Server-side app”,
“repository”: {
“type”: “git”,
“url”: “RivetCode123/DB_backend · GitHub
},
“dependencies”: {
“dotenv”: “^16.4.5”,
“express”: “^4.19.2”,
“mongoose”: “^8.4.0”,
“nodemon”: “^3.1.2”
}
}

The users array directly above.

Is it just me struggling with this?
router.get(‘/’, (req, res) => {
^

TypeError: router.get is not a function

Do you have the router properly defined?

import express from 'express';
const router = express.Router();

I appreciate all the help. I have been stuck on this a week already.
I changed that back to const router = express.Router();
then:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package ‘express.router’ imported from C:\Users\Kermit\Documents\Dev\dev10\routes\users.js

Sounds like you’re programming real-world web apps.

Every problem has a solution and finding it is part of the thing. That’s what professional programmers are doing (that’s where all of the stackoverflow questions and answers come from. Professional programmers correct me if I’m wrong here).

If you learned in a closed simulator environment where everything went smoothly, versions never changed and nothing was ever updated and you never needed to consult documentation on what got updated and how to change it, you would not learn as much.

That said, if something gets too difficult or you cannot find a solution, someone in this forum will help you.

Thanks PK, glad I’m not alone. My problem is I get through 3-4 modules and none of them work, I feel like I haven’t learned much. Then I’m back to create-react-app and start over again. Oh, and they deprecated that too. (#@)(% lol

1 Like

This is just bizarre: Two lines of code, one works, error on the other:

app.get(“/”, (req, res) => { res.send( “Hello from server!” );});
app.get(“/”, (req, res));

Error: Route.get() requires a callback function but got a [object Object]

I even added this:
var req = express.request.params;
var res = express.response.params;

this is not a function, as such it’s erroring out

this will not work, as req and res if you write the callback correctly, are function parameters, they get a value from app.get when it calls the callback, not from outside variables

1 Like

can i still do any courses if i dont have any money to donate now

1 Like

This is verbatim from the index.js in the lesson?
I think it’s included as the default root ‘/’ response. I’ll just remove it for now unless there’s a fix.

yes, all courses are free

It is a mistake in the article. You can look at the code in the linked to repo.

https://github.com/Aviatorscode2/crud-api-tutorial

Always check the repo code if one is provided.