Cannot install npm packages on ubuntu 16.04 - node.js

I have installed node.js and npm on ubuntu using aptitude but when i try to install any package like socket.io for example i get the warnings below:
username#server:~$ npm install socket.io
/home/username
└── socket.io#1.7.3
npm WARN enoent ENOENT: no such file or directory, open '/home/username/package.json'
npm WARN username No description
npm WARN username No repository field.
npm WARN username No README data
npm WARN username No license field.
Running:
Ubuntu 16.04.2 LTS
npm v4.4.4
Node.js v4.2.6
Anyone with any good ideas?

It shows just warning not error, your package got installed in node_modules.
It's best practice to create package.json always in root folder to install all required modules.
The warning also make sense, try to find package.json in /home/username/package.json
You can create package.json by command
npm init
follow the step during creation of pakcage.json

Related

Why am I getting an error when trying to install and run npm?

I am trying to install and run npm in a linux environment. I have executed the below code to try and achieve this
nvm install v11.0.0
nvm use v11.0.0
npm install
npm start
When I execute npm install in the command line I keep getting the following error message. Any advice to help this run is much appreciated.
npm WARN saveError ENOENT: no such file or directory, open '/home/andrewoca/PycharmProjects/pythonProject/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/andrewoca/PycharmProjects/pythonProject/package.json'
npm WARN pythonProject No description
npm WARN pythonProject No repository field.
npm WARN pythonProject No README data
npm WARN pythonProject No license field.
npm install is looking for package.json in order to see what it needs to do. Since you dont have it - you get the errors.
See https://docs.npmjs.com/cli/v7/commands/npm-install
Before running npm install, create an npm project.
This can be done with npm init -y
Now you can use npm install <package name>

Warnings when installing npm modules in project directories, but not when installing globally

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.

What am I missing when getting these errors installing Node on OSX?

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.

npm error messages when installing packages as sudo user

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

How to fix the "npm install error" when installing "Botkit"?

I am a newbie machine learning programmer trying get how to install the botkit tool for creating AI messaging bots from the bot kit studio.
Botkit was installed but the following errors are shown in my terminal:
Rakeshs-MacBook-Air:~ niharika$ npm install
npm WARN enoent ENOENT: no such file or directory, open '/Users/niharika/package.json'
npm WARN niharika No description
npm WARN niharika No repository field.
npm WARN niharika No README data
npm WARN niharika No license field.
Rakeshs-MacBook-Air:~ niharika$ npm install --productions
npm WARN enoent ENOENT: no such file or directory, open '/Users/niharika/package.json'
npm WARN niharika No description
npm WARN niharika No repository field.
npm WARN niharika No README data
npm WARN niharika No license field.
I can't seem to figure out what the package.json file is supposed to be in order to run botkit studio.
This error does not have much to do with Botkit, but more to do with where you are running the npm install. You are running it in your /Users/niharika path. If you cloned down botkit into that directory then you will need to cd into it first. Your path will look more like /Users/niharika/botkitslackstarter/. Then run npm install which will look for a package.json in the root and install all dependencies so then you will be able to run node bot.js to start the application. Best of luck.
Step 1:
npm install
Step 2:
npm install botkit

Resources