How to rename nodejs project?

Edit the name attribute in your package.json, that's what determines the name of your package.


if you're copying files from an existing project and still having issues after updating the name attribute in package.json, try removing node_modules dir and package-lock.json file (backup if needed) and run npm i or yarn.


Check out package.json. There should be a few properties in there that you can change (you want to change the name). A simple file would look something like this:

{
    "name": "gpio-editor",
    "version": "0.0.0",
    "author": "Sudo Programmer <[email protected]>",
    "description": "i use this to edit stuff",
    "license": "pick one",
    "engines": {
        "node": ">=0.10"
    },
    "scripts": {
        "start": "node ./app.js"
    },
    "dependencies": {
        // something or other, don't include comments though
    }
}

After that you should run npm install, which will update the file package-lock.json accordingly.

Edit (5/31/2018)

Since Node 5 (I believe), the package-lock.json file has been generated and used as an, "I last built this codebase using these dependency versions" tool. The package.json file is supposed to do this, but it doesn't protect you from packages that don't follow semantic versioning. For this reason, I would recommend checking the package-lock.json file in and updating the name there as well. There's some good info on the lock file here.