Manage Packages: Adding Dependencies

Hi All,

I’m new, and I’m trying to add version “2.14.0” of the “moment” package to the dependencies field of my package.json file. Here’s what I have, but it fails once I try to run the code. How do I add the package? Or rather, explain what I’m missing?

{
	"name": "fcc-learn-npm-package-json",
	"dependencies": {
		"express": "^4.14.0",
    "package-name": "moment",
    "version": "^2.14.0"
   },
	"main": "server.js",
	"scripts": {
		"start": "node server.js"
	},
	"repository": {
		"type": "git",
		"url": "https://idontknow/todo.git"
	}
}

Challenge:

Managing Packages with Npm - Expand Your Project with External Packages from npm

Link to the challenge:

You add a package by simply typing its name and version as a key value pair in the dependencies object. The key is the package-name and the version is the value.
Like this:

“package-name”: “version”

Remove "package-name": "moment" from there then do.

npm install --save moment@2.14.0 

This will add the package to the package.json as expected.
If you want to modify the package.json you need to add the package same as express is added then you will have to run a npm install. (or yarn)

2.14.0 is 5 years old. Are you sure you want to use this version?

This is the version the challenge looks for :slightly_smiling_face:

Oh snap! Fair enough
Spoiler alert! :upside_down_face:

"dependencies": {
  "moment": "2.14.0",
  "express": "4.14.0"
}

This should do.

Thank you everyone for clarifying! :grinning:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.