I am trying to install express via npm in node (nodejs). I am the user 'kev' and this user is sudo. I cannot use a sudo command to install anything as it cannot find npm at all when I 'sudo npm' for some bizarre reason. I have tried adding symbolic links but sudo'ing still refuses to find npm. So running as a standard user and trying to install express using npm I get the following errors:
kev#tentimes:~$ npm install express
npm WARN saveError ENOENT: no such file or directory, open '/home/kev/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/kev/package.json'
npm WARN kev No description
npm WARN kev No repository field.
npm WARN kev No README data
npm WARN kev No license field.
I have no idea what the errors mean, except that it seems to me it may be due to me not elevating to sudo to install using nvm. Anyone have any suggestions? It is my first time installing express with node/nvm and I am following some recent guides on how to do this, but the guides just say to use "nvm install express" and this is just supposed to work. As a by the way, I have git setup, but is that why it is complaining about repositories?
NPM is a package manager, and as it's name implies, it works with packages. A package is, basically, a folder or repository with a package.json file in it, which contains all kinds of metadata about the package. This file is missing as the error tells you:
ENOENT: no such file or directory, open '/home/kev/package.json'
Thats fine, it should install the package anyway, check the ./node_modules folder. However it's recommended that you yourself initialize a nodejs package with npm init which will ask you a few questions about the package you're going to write. Afterwards, npm install --save express installs express and saves the dependency in your own package.json file so the next time you can just npm install and npm will happily install all dependencies listed in your own package.json file.
Here is some more documentation about what the package.json is and what information it contains: https://docs.npmjs.com/files/package.json
Related
I have observed this issue when installing both newsapi and RequireJS. The path to my project directory is as follow: Users\username\project
In my project directory, when I run npm install newsapi --save (installation instructions per the newsapi site or npm install requirejs (installation instructions per the RequireJS site, I get the following identical warnings:
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\username\project\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\username\project\package.json'
npm WARN project No description
npm WARN project No repository field.
npm WARN project No README data
npm WARN project No license field.
It may be worth noting the project\node_modules\newsapi and project\node_modules\requirejs are still created and they seems to be populated as they should.
I noticed that when I install the modules globally (by running npm install -g newsapi --save or npm install -g requirejs) the installation succeeds without displaying any warnings. Why is this the case? What is happening in my project folder that might be causing this issue?
npm install fhqhwhgads will try to update the local project package.json but npm install -g fhqwhgads will install globally and so there's no package.json to update. So that's why you're note getting an warning with global installation.
If you want to create a package.json so that your dependencies can be tracked and replicated by others (or if you want to publish your code as a package), you can use npm init.
I am attempting to install newsapi via the command: npm install newsapi --save.
That installs two dependent packages (core-js and node-fetch) as well as newsapi itself. I run the command in my project folder. I have no issues with core-js and node-fetch, but I get the following warnings regarding newsapi.
npm WARN saveError ENOENT: no such file or directory, open 'Users/user_name/project/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'Users/user_name/project/package.json'
npm WARN project No description
npm WARN project No repository field.
npm WARN project No README data
npm WARN project No license field.
After the installation, package-lock.json is created in my project folder and Users/user_name/project/node-modules/newsapi/package.json does exist. I don't know why the installation asks me to open Users/user_name/project/package.json. Why would it be in my project folder and not in the module's folder?
I tried solutions I read in other threads including deleting package-lock.json and retrying the installation and using npm init. Neither of those methods worked.
I also tried copying and pasting package.json to the project folder (because the warnings prompt me to open Users/user_name/project/package.json) but that did not solve my problems either.
How can I successfully install the module?
Running npm install node (done successfully before on other machines) but now getting the following
npm WARN saveError ENOENT: no such file or directory, open '/Users/USERID/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/USERID/package.json'
npm WARN USERID No description
npm WARN USERID No repository field.
npm WARN USERID No README data
npm WARN USERID No license field.
Not sure what to do and searching around didn't yield results
Tried running via sudo
Tried installing from the Node website pkg
Searched around stackoverflow
Hoping to get this installed.
npm is a package manager for Node.js, and is not itself used to install Node.js.
You will want to either:
Download the pkg from here and install it: https://nodejs.org/en/download/
Use a package manager like nvm: https://github.com/nvm-sh/nvm
I recommend you get the LTS version.
I'm running node.js 8.9.4 on Windows 10.
I'm trying to install the 'connect' module because I need it for a project. It's definitely not installed yet, because if I try to require it, I'm told that it can't find 'connect'.
But when I type npm install connect, the first time, it seems to work but has quite a few warnings and seems to remove a lot of packages. It says:
npm WARN saveError ENOENT: no such file or directory, open 'D:\Program Files\nodejs\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'D:\Program Files\nodejs\package.json'
npm WARN nodejs No description
npm WARN nodejs No repository field.
npm WARN nodejs No README data
npm WARN nodejs No license field.
+ connect#3.6.6
added 9 packages, removed 473 packages and moved 3 packages in 3.991s
(Not sure why it's removing 473 packages, might be related). Anyway, it seems like maybe it worked, and then I realize that in nodejs/node_modules, the npm directory is nowhere to be found. And now, if I try to install any packages, it gives me a bunch of errors, basically telling me:
Error: Cannot find module 'D:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
Connect has been installed, but at a cost that seems...not quite right (I can't install any more packages!) Obviously I'm new to node.js, please send help. And I hope that I don't get banned from asking questions again because I'm pretty clueless. Did the best I could to be specific.
It seems trying npm install in uninitialized npm package directory.
You should initialize package with npm init.
You can find out more https://docs.npmjs.com/getting-started/using-a-package.json
I was installing an encryption package for node when I received this ENOENT error.
$ npm install crypto2
C:\Users\adity
`-- crypto2#0.3.1
`-- node-rsa#0.4.2
`-- asn1#0.2.3
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\adity\package.json'
npm WARN adity No description
npm WARN adity No repository field.
npm WARN adity No README data
npm WARN adity No license field.
As for looking in the path the error describes, I looked there and found an old version. I did an uninstall from npm (which also received the same error). Then I had to manually remove it and empty from the trash.
I also tried to install it globally, again, to no success.
I am using git bash command prompt for this, and tried the same thing with node.js command prompt with it returning the same errors. The package I'm installing is (if this will be any help) : https://www.npmjs.com/package/crypto2
EDIT: I just discovered this problem isn't just with the encryption package but any package that I try to install. When I tried installing Requirejs, same error. This is weird, because I installed a couple of packages yesterday (Passport.js) which installed perfectly without any hiccups whatsoever.
It's just warning you that it didn't find a package.json. If you don't have one or need one, then you can just ignore it.
If you want to create one and add the dependencies to it automatically, you could do:
npm install crypto2 --save