How do you use dependencies in npm?

I’m in the backend and API course of freecodecamp, the part where it tells you to “Expand your project with external packages from npm” the instructions tells me to add version “1.1.0” of the @freecodecame/example package to the dependencies field of your package.json file. It says that I need to store it in this format. I was trying different things for almost an hour now and I would appreciate it if someone could explain to me what is going on and how I can fix this, thank you!

"dependencies": {
  "package-name": "version",
  "express": "4.14.0"
}

I’ve pasted the link of the browser into freecodecamp and this came up:
// running tests

"dependencies"

should include

"@freecodecamp/example"

.

"@freecodecamp/example"

version should be

"1.1.0"

. // tests completed

This is my code so far

{
	"name": "fcc-learn-npm-package-json",
	"author": "A",
	"main": "server.js",
	"keywords": ["title", "pattern", "required", "freecodecamp"],
	"license": "MIT",
	"version": "1.0",
  "dependencies": {
    "package-name": "@freecodecamp/example",
    "express": "1.1.0"
	},
	"description": "A starter project for my learning journey with freecodecamp",
	"scripts": {
		"start": "node server.js"
	},
	"repository": {
		"type": "git",
		"url": "https://idontknow/todo.git"
	},
	"dependencies": {
		"express": "^4.18.1"
	}
}

https://boilerplate-npm-1.air-conditionin.repl.co/

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: Managing Packages with NPM - Expand Your Project with External Packages from npm

Link to the challenge:

The instructions state:

Add version “1.1.0” of the @freecodecamp/example package to the dependencies field of your package.json file.

Instead, with the package.json screenshot above, you tried to add a package named package-name with a version of @freecodecamp/example and then changed the version of the existing package express to be 1.1.0.

To fix your issues:

  1. Do not change the express package version.
  2. Add a package named @freecodecamp/example with its version being 1.1.0.

There should only be two packages listed in the dependencies section when you complete this challenge. One is @freecodecamp/example and the other is express.

Thank you very much for reaching out, I’ve tried fixing it the way you told me to but without luck it doesn’t work. This is the error message it :
// running tests "dependencies" should include "@freecodecamp/example" . "@freecodecamp/example" version should be "1.1.0" . // tests completed
and this is the code. I tried deleting line 20 to 22 because in the original package, it doesn’t exist but the error messages come up.

Please post a link to your latest project code.

https://boilerplate-npm-1.air-conditionin.repl.co/

When I look at your package.json file, I see two different dependencies sections. There should only be one dependencies section and it should contain the original express package and version plus the new dependency and version you added (correctly).


I got an error message after putting the original express with the new express.

Why do you have two express in your dependencies section? Also, you need to make sure that you are putting commas were appropriate within dependencies.

I added a comma at the end of line 9 and the same error messages still pop up.

Did you git rid of the incorrect express?

Which one is the incorrect express?

Look at the package.json file by clicking on the starter code link in the challenge and you will see.

This is the original starter code:

This is my code, I tried running it again but results are the same

And just like I said before, you should only have one instance of express listed in dependencies. You still have two.

My build was failed in Heroku after add the following
@freecodecamp/example”: “1.1.0”,

The error i got
Installing node modules

   npm ERR! cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.

   npm ERR! 

   npm ERR! 

   npm ERR! Missing: @freecodecamp/example@1.1.0

   npm ERR!

ii executed the npm install in the command line even though it fails.