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?
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:
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?