Global NPM package not installing - javascript

I have written a command line utility in JS which can be used to backup data to IPFS.
https://www.npmjs.com/package/ipfs-backup
When I am attempting to install it with npm install -g ipfs-backup I am getting an error which prevents the package from being installed.
The terminal is outputting the following:
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path C:\Users\jwhit\AppData\Roaming\npm\node_modules\ipfs-backup\node index.js
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, chmod 'C:\Users\jwhit\AppData\Roaming\npm\node_modules\ipfs-backup\node index.js'
npm ERR! enoent This is related to npm not being able to find a file.

The issue turned out to be that within my package.json file I had
"bin": {
"ipfs-backup": "node index.js",
"ipfs-restore": "node restore.js"
}
instead of
"bin": {
"ipfs-backup": "./index.js",
"ipfs-restore": "./restore.js"
}
It installs and functions correctly now.

Related

I get an error whenever i try to run "npm install" on visual studio code

whenever I run npm install I get this error
I am on node version 18.9.1 and I have tried every single solution please help
'''npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\ASUS\OneDrive\Desktop\cw/package.json
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\ASUS\OneDrive\Desktop\cw\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent'''
npm install --force did the trick. I also had to add "type": "module",
and also I was using got so instead of require() I used import

New to react could not start server got error messages any idea?

PS C:\Users\USER\Desktop\react> npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\USER\Desktop\react\package.json
npm ERR! errno -4058
'C:\Users\USER\Desktop\react\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Roaming\npm-cache_logs\2020-10-15T10_23_32_090Z-debug.log
It looks like you're trying to run an npm script such as "npm start" in a folder that doesn't have a "package.json" file. Make sure you are in your React project's working directory and try again.

Getting error while installing udev module in node js

I'm runnig command :
npm install udev
And I'm getting this error:
npm WARN enoent ENOENT: no such file or directory, open '/home/mitesh/package.json'
npm WARN mitesh No description
npm WARN mitesh No repository field.
npm WARN mitesh No README data
npm WARN mitesh No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! udev#0.6.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the udev#0.6.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/mitesh/.npm/_logs/2020-03-16T11_44_35_032Z-debug.log
Looks like you do not have a package.json in your project or it is probably not rightly placed. Here is what you can do;
Browse to your project directory and run this command;
npm init
This should create a package.json file in your project directory
Then run,
npm install udev --save
--save will ensure your module is saved as a dependency in your package.json file.
you could just try to run the last command without the --save but in some cases it helps
Here is a link to further assist: npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'
Try this let me know if it helps.

How to add a new script in package.json

I want to add a script dev in my package.json.
I tried adding it manually in a text editor, but when I run:
npm run dev
I get some errors. Is it possible to add the script from the terminal?
Edit:
I added:
"scripts:" {
"start": "node app",
"dev": "nodemon app"
}
and I got this error:
nodemon app sh: nodemon: command not found
npm ERR! code ELIFECYCLE npm ERR! syscall spawn
npm ERR! file sh npm ERR! errno ENOENT
npm ERR! code#1.0.0 dev: nodemon app npm ERR! spawn ENOENT
npm ERR! npm ERR! Failed at the code#1.0.0 dev script.
The problem here is you have not installed the package named nodemon:
In your CLI enter the following command to install the package:
npm install nodemon --save-dev
Then run the following command and it will work:
npm run dev

How can I create a node CLI app that needs babel to run?

I'm trying to creaet a global node CLI app, but It depends on Babel to run.
I've added this to my package.json
"bin": {
"kurly": "dist/index.js"
},
"scripts": {
"prepare": "npm run build",
"build": "babel src -d dist",
"start": "yarn build && node dist/index.js"
},
and I'm installing it from my git using
npm install -g alexanderprod/kurly
But when installing it I get the following error
npm ERR! path /usr/local/lib/node_modules/kurly/dist/index.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/kurly/dist/index.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
So it seems like npm didn't build it with babel before applying chmod.
And now I'm wonderging how to fix that, since I assume it makes no sense to upload dist/ to npm/git

Categories