npm problems with windows - node.js

I've looked through the different articles here, but I'm not finding out the answer I need, or don't understand necessarily what has been explained in other posts.
I downloaded node.js got my github up and have cloned the phonecat site, that part works fine. I can even check npm/node versions through cmd, but whenever I install using either "npm install" or "npm install -g" "Couldn't read depndencies" couldn't find package.json" has a long list of errors:
http://tinypic.com/1r54rjf4
I have tried caching, updating, restarting, uninstalling, reinstalling, giving permissions to fully allow windows system32 for commands. I have been reading for a few hours, and I am just at a complete loss here. Any help would be greatly appreciated!

When you don't specify a module to download, npm will look for a package.json. It's not finding one, which is why you're seeing all kinds of errors.
Is there a project you're working on? If you want to start a new one you can run npm init. If there's an existing one that has a package.json, you can navigate to that directory in your terminal and then npm install should work.

I didn't. I'm still wrestling with it. I'm not sure what to do about it either. I had one of my friends come over that's familiar with node and he couldn't figure it out. It must be a permissions issue somewhere on the computer. I can't figure out what else it could be.

Related

Running a local dependency in WSL2

A beginner here. I started my journey into coding a couple of months ago and finally I have decided to set-up WSL2. I have successfully installed WSL2 together with NPM and Node.
I have created a test project to start playing with, where I have installed parcel-bundler as a local dependency using npm. The package.json file gets updated to include parcel-bundler, so all good up to here.
package.json file
However, when trying to start parcel, I get a message from my terminal saying that parcel command be found!
terminal parcel not working
I am pretty sure there is a little thing I am missing here, but have spent hours looking for an answer but havent been able to find anything.
Any advise would be greatly appreciated, and let me know if you need any more info from my side.
Cheers,
Alejandro

Why does my computer keep forgetting node and npm installation?

My computer keeps forgetting that I have node installed despite the fact that all of the files are still there. So far, I have tried installing through the node installer on the nodejs website, using brew, using nvm, and also several of the suggestions in this gist. No matter what I try, within a couple of hours or a couple of days, I am working away and then I am suddenly throwing node errors, and when I check node -v or npm -v, I get the error command not found: node or command not found: npm. The only thing that I can figure out to get node working again is to uninstall whatever I most recently tried and then to reinstall.
It seems like I might be having some sort of env or path issue, but I don't know where to begin to start troubleshooting anything like that.
EDIT
Based on the suggestion below, I added these to my .bash_profile and it seems to have fixed my issue. Not sure why the install wasn't adding them here or in .bashrc, but adding it manually fixed the issue:
export PATH="$HOME/.npm-packages/bin:$PATH"
export PATH="$HOME/.node_modules/bin:$PATH"
maybe you forgot to add node & npm binaries to your path that's why when you open a new instance of your terminal it says that it doesn't know node and npm
Simply add the line that register the binaries into your path within your .profile file that might be located in your home directory

How to resolve bycrypt dependency issue in module.

I keep getting this issue:
[snip of my issue][1]
I'm teaching myself node and am trying to make a CRUD RESTful application in my spare time. I'm working off this book:
https://leanpub.com/mean-machine.
For the past 3 days I've been stuck with this issue. It is specifically concerning the bcrypt-node.js . It's job is to hash passwords. Some things I have tried.
Downloaded python 3.5 as I got errors saying the runtime was needed to execute.
Setting python environment variable in PATH
npm uninstall and install.
Tried creating a new project, same issues cropped up.
npm clear cache
Since it is an old version of the bcrypt-node.js module changed the version in package.json from "0.0.3" to "0.0.5". I thought it could be a bug. Unlikely as that is.
I'm very new to node.js so I feel like I'm doing something silly that I just cannot see. Also I don't understand a lot of the information the command line is providing me. Thank you in advance.
EDIT 1:
Picture of my code.
Edit. (For future visitors) I needed to pay more attention to the various dependencies and a further understanding of JS in general to utitlise the power of Node.js, which is something I didn't do. Also recommended is a good understanding of Express.
A deeper understand of the npm is needed.
I found a fix through trial and error and some googling.
In case any one looks up this again in the future I entered:
npm install node-gyp -g && npm cache clean && rm -rf node_modules && npm installinto the command line and it appeared to fix the issue when I ran nodemon server.js
Fingers crossed it does not crop up again.
If someone would like to explain to me what exactly was the problem I had I would really appreciate it. I have a feeling a module or dependency wasn't installed correctly?
EDIT 1. Furthermore configure the PATH in your environment variables.
ie I created a path for python in the command line
PATH python = C:\Python27\python.exe & another PATH for MongoDB
i.e C:\Program Files\MongoDB\Server\3.2\bin

Issues installing swiper.js (node.js/grunt noob)

Having issues getting swiper.js to work. Requires grunt/bower. I'm completely new to js generators and am only able to get through about half the walkthrough before running into issues.
When I type $grunt dist into terminal, I get the following response: -bash: dist: command not found
What step am I missing?
Followed the idangerous steps to the letter: http://www.idangero.us/sliders/swiper/plugins/scrollbar.php
I have most often see "X command not found" for one of the following reasons:
The project's Grunt dependencies aren't installed or aren't installed properly
Your Gruntfile is mis-configured or missing
To fix this, first make sure there is a package.json file in your project. This will tell the npm what dependencies the project has and install them accordingly (assuming the package.json file is also configured correctly).
Next, make sure you have installed grunt correctly.
If you're still having issues, open your Gruntfile and search for:
grunt.registerTask('dist
This will show where the "dist" task is being defined. If you for some reason don't find it, then there's your problem. If you do find it, then check the proceeding commands inside square brackets that look like this:
grunt.registerTask('dist', ['clean', 'dist-css', 'copy:fonts', 'dist-js', 'dist-docs']);
'clean', 'dist-css', etc. are all other tasks defined in the Gruntfile, and there could be an issue with those as well.
If there's an issue with your package.json or Gruntfile, then trying re-installing the project with bower and repeat the above steps to ensure that it's not an issue on your end.
If it's not, then something is probably wrong with the author's source code.

Node won't run, just exits code 0

Well some days ago I was tired to always call sudo when calling npm install and that sort of things so I tried uninstalling node and tried installing via Homebrew, I managed to make a huge disaster but finally it worked. Until now...
When I run node app.js or npm install it just doesn't do anything.
I tried deleting the related files like this.
I tried using nvm.
Tried the manual install with the .pkg file from the node homepage.
Tried through homebrew again.
And still no luck; however if the Node app has compilation errors I get the error stack, but when everything is "ok", instead of start listening for incoming connections it just exits with code 0.
Ok, I feel reaaaaaaaaally stupid after I found the issue, in my postgresql config I had the wrong password for the database and for some reason caused all this mess. Will upvote all of you, will understand if you downvote me for being such a moron.
OneOfOne's node debug then keep pressing s did the trick for me.

Resources