Issue cloning every repository - node.js

I have been cloning repositories with node and MongoDB but I always run into issues running npm install when I cd into the folder directory.
It has to be me because I happens every time. What am I missing?
Seems like npm install is the 3rd step after 1: git clone "repository link", 2: cd in clone folder.
Please guide me in the right direction.
Thanks a ton

You can run npm install from a directory where package.json file is located since this is the one which holds all the info regarding packages.
So just try to make it sure that the directory from where you are firing npm install command, have package.json file.
Apart from this, just check if you have npm installed. Run npm -v

Related

how to un-init NPM?

So oddly I really cannot find the answer to this question and after a few posts and docs I've looked at on NPM I've decided to ask the question - which may be a very basic one but doesn't seem to be implicitly addressed...
How do you uninstall npm from a dir?
Premis:
you npm init -y on the wrong directory
desired outcome:
to remove npm from that directory
I'm working on windows 10 / using git bash on VS code terminal
any help here would be appreciated -
Wally
All npm init does is setting up package.json for you (guided or not). If you just del package.json from the wrong directory, you should be good to go.
Deleting the package.json from the wrong directory should do the trick.
You will have to keep in mind that if in case you have run the npm i or npm install commands after npm init you will also have to delete the node_modules folder (as it usually takes plenty of disk space) and run npm i now in the correct directory.

How do I get spectacle-code-slide working on Windows?

I have installed Node on a Windows 10 machine. Then did npm install spectacle from the node command prompt. Finally downloaded the spectacle-code-slide zip file. Moved into the folder, did npm install and npm start. I get the following:
npm ERR: missing script: start.
Obviously, I am missing something. What is it? Note: I am a complete noob!
Edit: I tried the process outlined here without success.
This error means that you don't have start script in your package.json. Read about scripts here.
When you run npm instal spectacle you install spectacle as a package into node_modules folder. So you don't have any scripts in your package.json except those you add there yourself.
I've actually never used spectacle, but I suppose you better use their spectacle-boilerplate (instead of doing npm instal spectacle). You need to clone (via git) or download that repository locally. And then you will have their package.json with start script in it.

'npm EER! code 1' When installing dependencies using `npm install --production`

I am using flightplan to deploy my node.js application to my server. I run the command fly production in my CLI to deploy my app to the server. It does rsync fine, but when it comes to installing dependencies, I get the following error:
I made sure that I have sudo privileges on my server for this user and npm is definitely installed as it gives the version number when I run the command npm -von my server. I have tried to run npm install --production myself on the server as the deploy script does and I get the same error, meaning it is something to do with installing dependencies. Potentially, it could be because in my flightplan.js, when it runs the command git ls-files to get the files to copy across. it includes all the node_modules even though i've made sure that node_modules is in the .gitingore file.
Does anyone have experience with flightplan npm module/or know why my npm install isn't working on my server?
(I edited out my server IP address from the picture)
Thanks in advance!
I found that if I removed the node_modules folder by running command rm -rf node_modules/ then committed this to github, then re-ran npm install and then my call to fly production worked successfully.

npm install in a specific local folder

I'm currently trying to execute the command npm install to get all dependencies and modules necessary to run my package.json.
The problem is that I don't have Internet access to fetch from the internet, so I have downloaded the node_modules on a different PC and copy-paste it on my local folder that contains all. If I tried to run npm install without arguments, it's still trying to fetch from internet and fails.
I have read their documentation and apparently they have listed few npm install that takes different arguments, but still, I'm unable to install from the folder already downloaded.
I've tried to do npm install node_modules on the path that contains the package.json, but nothing. I'm running on windows 7.
If someone has an approach to specifying the local node_modules and just install all modules inside, I'll appreciate.
Thanks!
You probably should use npm-link...
From the docs:
Go to the node_modules directory, and, inside each package, run npm-link:
$ cd node_modules
$ cd package-name
$ npm link
$ cd ..
...
In the directory of your project which needs the local modules:
$ npm link package-name

npm install resulting in 'ENOENT: no such file or directory'

I've installed Node.js for Windows and I'm trying to install a package via npm. The command prompt is in the directory of the project (C:\Users\username\Desktop\NodeTest), which contains a single helloworld.js file. Upon typing 'npm install express', I receive the following error:
ENOENT: no such file or direcotry, open 'C:\Users\username\package.json
I'm attempting this from a clean install and cmd is running as admin.
Any ideas?
I was facing the same issue. I firstly delete my node_modules and delete the cache by following command:
rm -rf node_modules && npm cache clean --force
then I delete the package-lock.json file from my project and then hit npm install in command prompt and it works.
As already pointed out by Subburaj this is because you are missing a package.json.
Just run npm init to initialize that file for you; afterwards it should work.
If you are working on a Windows machine using Vagrant/VM, there's a chance that symlinks are the culprit for your problem. To determine if that is the case, simply copy your package.json and package-lock.json into a test directory that is not mounted/shared between OSs.
mkdir /tmp/symlinktest
cd {{your directory with your package*.json}}
cp package*.json /tmp/symlinktest
cd /tmp/symlinktest
npm install
If this results in a successful install, you'll need to either exclude the node_modules directory from the mount (there's various articles on doing this, however I can't say I've had success) or run npm install outside the mounted volume.
I deleted the package-lock.json and It worked for me.
Basically I was Offline while I tried to install with npm, so go online and try
npm install again
Check the project folder which you opened in microsoft visual code. Generally you are not in the right path so npm is not able to search the package.json ... My project was in Document/hostel/hostel .. I opened Document/hostel ... So npm tried to find the package.json in Documents folder .. When i entered one level inside to Document/hostel/hostel .. it was fixed.

Resources