Can't add package in package.json

So, basically, I’ve made a website with a package.json file, but I’d like to add a package to it, but I can’t because when I make a new package.json file, the ‘add package’ button doesn’t work - it just sits there, grey and useless. I’ve experimented with this in other projects aswell - only package.json files that are there by default work. Any ideas of how to overcome this, other than copying and pasting loads of files over to another project?

Hey @Pufferfish101007,

If the ‘add package’ button doesn’t work, it usually means there’s a syntax error with your package.json. Please post the entire contents of the package.json so that I can take a look!

It’s just an empty file called package.json. That’s it.

Ah, your package.json file needs some content for dependencies to be added.

1 Like

Add this:

{
  "//1": "describes your app and its dependencies",
  "//2": "https://docs.npmjs.com/files/package.json",
  "//3": "updating this file will download and update your packages",
  "name": "hello-express",
  "version": "0.0.1",
  "description": "A simple Node app built on Express, instantly up and running.",
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.17.1"
  },
  "engines": {
    "node": "12.x"
  },
  "repository": {
    "url": "https://glitch.com/edit/#!/hello-express"
  },
  "license": "MIT",
  "keywords": [
    "node",
    "glitch",
    "express"
  ]
}
2 Likes
{
  "main": "server.js",
  "scripts": {
    "start": "node server.js"
  },
  "dependencies": {
    "express": "^4.17.1",
  },
  "engines": {
    "node": "12.x"
  },
}

A shorter version if you only need to install dependencies.

1 Like