Whenever I start my nodejs project, it refers to itself by the old name I gave it:
gpio-editor@0.0.0 start /home/pi/RPi-Computer-Power/RPi-Server
I do not want it to be called gpio-editor anymore, but I have not found a way to change it on the interwebs. I am pretty new to nodejs, and I didn't originally make this project.
If someone knows how to do this, please let me know. Thanks, Neil
Edit the name attribute in your package. json , that's what determines the name of your package. Save this answer. Show activity on this post.
fs.rename() method accepts two arguments, the current folder name you want to rename and the new folder name, and asynchronously renames the folder. Here is an example: const fs = require('fs') // directory paths const oldDirName = './images' const newDirName = './img' // rename the directory fs.
js using fs module. Node FS Rename File – To rename file with Node FS, use fs. rename(new_file_name, old_file_name, callback_function) for asynchronous file rename operation and use fs. renameSync(new_file_name, old_file_name) for synchronous file rename operation.
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With