I am trying to install MongoDB on my personal machine for a Node project through the command line using npm install --save mongodb. MongoDB shows up in the dependencies in my package.json file with a current version, but when I run mongodb -v, mongod, or just try to open up the mongo shell by running "mongo" I get these errors:
"command not found: mongodb"
"command not found: mongod"
"command not found: mongo"
I have also tried running sudo mongod to no avail. Does anyone have any suggestions? I have looked at a lot of documentation at this point and am not sure where to turn.
Looks like you're just installing the node.js driver for Mongodb. npm is generally used as a package manager solely for node.js packages and dependencies. You need to install the actual database system using the binaries or a binary package installer e.g. Homebrew.
https://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/
https://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/
Related, and looks like your same issue.
Related
I'm on Windows 10 (version 10.0.17763 build 17763). I'm trying to install Bcrypt with Nodejs Express server using NPM. I've updated the latest Nodejs version (v12.16.3). Whether I install the latest version of Bcrypt or an earlier version, I'm always getting the same error:
I'm not sure why it's looking for node-pre-gyp\bin\node-pre-gyp in the directoy C:\Users\hazzaldo\Desktop\web-dev-udemy-course\. There's no such directory there!! This is just a folder to store my course files.
Also I'm not sure why this is happening:
-Security\store-confidential-data-web-app\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file
I've looked in other forums for such error, but no solution helped me. Some are old forums asking to install deprecated modules.
Ok, after two days of pulling my hair out, trying solutions out and not getting anywhere, I finally found a reddit post with someone having exactly the same issue as me: https://www.reddit.com/r/node/comments/gahkjl/npm_drives_me_crazy_for_months_looks_for_bin/
It's because I used the & character in my folder name. I guess for some reason it throws npm off. Removing this character from my folder name resolved it.
https://www.npmjs.com/package/node-pre-gyp
That is an NPM package, I would say install node-pre-gyp and then try to install bcrypt
node-gyp is a dependency of bcrypt
I just ran 'npm install bcrypt --save' and it worked
or install this https://www.npmjs.com/package/node-gyp
Note dependencies from package.json,
Install packages individually.
In my case, I tried adding sqlite
"dependencies": {
"sqlite3": "^5.0.2"
}
and ran npm install, which did not work.
But then, removed it ,
"dependencies": {}
and ran
npm cache clean
npm install -g node-gyp
npm install --save sqlite3
Solved the issue.
OS:
macOS Sierra v 10.12.6
I am trying to build an application in Typescript using the typeorm and this is my first time using either.
I've used both of the following to install typeorm:
npm i -g typeorm
&
sudo npm i -g typeorm
And am seeing the following in the terminal after installing:
+ typeorm#0.2.21
added 127 packages from 406 contributors in 7.081s
But when trying to use typeorm CLI commands:
typeorm init --name jwt-express-typeorm --database sqlite --express
I keep getting this error:
bash: typeorm: command not found
I've tried uninstalling the package globally using:
sudo uninstall typeorm -g --save
and reinstalling afterward but still getting the same error. Any help would would be super appreciated!
If you don't care to add the global node_modules folder (not just the project one) to your $PATH, you can use npx {command-name} instead. The global node_modules folder's location depends on your OS. See Where does npm install packages?. One benefit of using npx, however, is that it works with all packages, not just globally installed ones.
try appending npm run before typeorm
After setting new windows in my laptop,i am trying to install npm in command prompt.But i am facing an error which picture is given in below.Would anybody help me out?
If you don't specify a package to install (like npm install -g nodemon) npm will try to install all packages from the current package.json file. If there is non, npm will throw this error.
Npm is already installed. That is why the error message is not Command not found.
The specific command you issued npm install -g attempts to use npm to install the package in the current directory globally.
Leaving the point that installing packages globally is a bad idea aside, this is failing because you are running the command in a directory that does not contain a package. It is your home directory, not one containing a package.json file.
If you are trying to install npm(node package manager) do it by downloading it from here: https://www.npmjs.com/get-npm, then you are good to go.
The command you are actually giving is to install a package using npm(check https://docs.npmjs.com/cli/install).
Thats why the error shows could not install from "" as you have not specified any package to install.
I have a project which I will have to deploy to client Windows systems where it will not be possible to connect to internet. I currently have a folder in D:\NODE which contains node.exe and npm.cmd and a node_modules folder. To be able to run node from command line I have added D:\NODE to PATH variable.
I can have most of the modules installed locally inside node_modules of my project. However there's one - node-windows - which needs to be installed globally to work.
Following suggestion below I went to node-windows (installed globally) and packaged it up (npm pack), which created a tarball. I have then copied that file with my project and tried to install it on the test machine globally like this: npm install -g node-windows-0.1.5.tgz
I can see that it got installed in the global directory. However when I try to run the command which uses this module it complains that it cannot find it: Error: Cannot find module 'node-windows'
When I list the modules (npm list -g) it is clearly there in the list...
What do you think? And thank you.
You can install packages on a system without internet connection by packing them using built-in functionality in npm. This way, the node modules will be installed properly.
Create a package.json.
In your package.json, list all the modules you need under bundledDependencies (docs on npm).
Run npm install to install your node files before packing.
Create a tarball with npm pack.
Copy the tarball over to the machine without internet connection.
Install the modules with npm install <filename>.
Update
Regarding your comments, it looks like your globally installed node modules isn't found.
Try using the npm link command (docs on npm link):
cd yourAppFolder
npm link node-windows
1 - In system with internet access install module with this command:
npm install [module name]
2 - go to %userprofile%\AppData\Roaming\npm\node_modules[module name]\
(e.g C:\Users\janson\AppData\Roaming\npm\node_modules\grunt-cli)
3 - run npm pack
4 - this should result in a [module name]-x.y.z.tgz file
5 - run npm i -g [module name]-x.y.z.tgz in offline system
I am using Windows Server 2008 R2 EE OS. In which I have npm package manager. I am trying to run the below command to install Selenium Webdriver package.
Command:
npm install selenium-webdriver
I am receiving below error while doing it.
Error:
node.js npm should be run outside of the node repl in your normal
shell
You are running the npm command inside the node shell.
Open another shell and just type "npm install bla-bla", npm should be on the PATH. Or cd to its directory and type command.
See my command images
Doing it wrong
Doing it right
In the case of windows, sometimes it is bad to consider that the npm will create folder itself for what it required.
The best is to manually create npm folder like "C:\Users\username\AppData\Roaming\npm".
Hope this help.
By creating a folder C:/Users//AppData/Roaming/npm solved my problem.