Installing NPM packages conflicting with Node.js 5.0.0 - javascript

I am trying to install npm packages, which i need for my code to work.
However when i try to install any npm package, it gives the same error:
Your environment has been set up for using Node.js 5.0.0 (x64) and npm.
C:\Windows\System32>npm install mime
C:\Windows\System32
└── mime#1.3.4
npm WARN ENOENT ENOENT: no such file or directory, open 'C:\Windows\System32\package.json'
npm WARN EPACKAGEJSON C:\Windows\System32 No description
npm WARN EPACKAGEJSON C:\Windows\System32 No repository field.
npm WARN EPACKAGEJSON C:\Windows\System32 No README data
npm WARN EPACKAGEJSON C:\Windows\System32 No license field.
C:\Windows\System32>
I have tried re-installing node.js twice, but this didn't work. I've also tried to run it as administrator and install it again, which didn't work.
My classmate also works with node.js, but whenever he isntalled node.js everything worked fine from begin, also installing npm packages.
I'd really appreciate your guys help!
Sincerely,
Ivar

The error messages you're receiving aren't telling you the installation failed, just that you don't have a package.json in the system32 folder. For global install add -g to the installation:
npm install -g mime --save
--save just means you save it to your package.json if you're in a root project that has a package.json.
There should be a node_modules in system32 provided you have writing access to it. (sometimes you need to enable that even for admins).

Well, actually it installed package. Check node_modules folder.
It complains that you don't have package.json file and README, etc.

Related

ENOLOCK npm ERR! Error while running npm audit fix

I am trying to install GLOBALLY a package with npm from my home directory. After the install has completed, it indicates vulnerabilities. Upon trying to run npm audit fix, I obtain the following error.
npm ERR! code ENOLOCK npm ERR! audit This command requires an existing
lockfile. npm ERR! audit Try creating one first with: npm i
--package-lock-only npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file
I understand that the error asks me to run npm i --package-lock-only, but in which directory should I be creating this file? Running the command without specifying a path does not work. I have also tried to create the file in the directory where the package was installed, but that has also not solved the issue. Also, why isn't this file present to start with?
npm audit fix is intended to fix vulnerabilities with the dependencies of your own project. Projects do have a package-lock.json file.
It is not intended for globally installed packages. If there are vulnerabilities with packages from others, they need to be fixed by the package maintainer in a new release. You can then update to this new release.
BTW, you should not use globally installed packages. Use npx instead.

npm installation in command prompt

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.

Why is node installing globally instead of locally?

So I navigated to my project directory and run npm install scrollama intersection-observer. It installed the files on my HOME/node-modules instead of the project folder. During installation there were warnings, though:
npm WARN saveError ENOENT: no such file or directory, open '[my-home]/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 '[my-home]/package.json'
npm WARN [my-user] No description
npm WARN [my-user] No repository field.
npm WARN [my-user] No README data
npm WARN [my-user] No license field.
So why did it installed globally (or, in my home instead of my project folder)?
Because your folder is not a valid npm install location as it could not find the package.json. to create that, just run:
npm init
You are not using npm init. npm init will initialize your node project and will make a package.json file. package.json file will store the information about the project such as project name, version, description and also the dependencies you download.
In your case there is no package.json file, because of this your packages are been installed to the home directory instead of current directory.
Also you can also use parameters like -g to install package globally (to the home directory) without any parameter, node will install the package in the current directory by default.
Installing locally: you can use the package inside your project.
Installing globally: you can use the package everywhere. Commands like nodemon are installed globally because you want to use these in every project.

npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'

I just want to install socket.io to my project which is located on 3.chat folder. But when I run following command it shows following Warnings.And its not created a node_modules directory inside my project folder. How to fix this?
C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm install socket.io
C:\Users\Nuwanst
`-- socket.io#2.0.3
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'
npm WARN Nuwanst No description
npm WARN Nuwanst No repository field.
npm WARN Nuwanst No README data
npm WARN Nuwanst No license field.
If you already have package-lock.json file just delete it and try again.
Have you created a package.json file? Maybe run this command first again.
C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm init
It creates a package.json file in your folder.
Then run,
C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm install socket.io --save
The --save ensures your module is saved as a dependency in your package.json file.
Let me know if this works.
Make sure you are on the right directory where you have package.json
You need to make sure that the package.json file exist in the app directory. Run this command where package.json file exists.
For more explanation, I run npm start in c:\selfPractice, but my package.json is in c:\selfPractice\frontend. When I switch to c:\selfPractice, it works.
NOTE: if you are experiencing this issue in your CI pipeline, it is usually because npm runs npm ci instead of npm install. npm ci requires an accurate package-lock.json.
To fix this, whenever you are modifying packages in package.json (e.g. moving packages from devDependencies to Dependencies like I was doing) you should regenerate package-lock.json in your repository by running these commands locally, and then push the changes upstream:
rm -rf node_modules
npm install
git commit package-lock.json
git push
If your folder already have package.json
Then,
Copy the path of package.json
Open terminal
Write:
cd your_path_to_package.json
Press ENTER
Then Write:
npm install
This worked for me
finally, I got a solution if you are getting:-
**npm WARN tar ENOENT: no such file or directory,.......**
then it is no issue of npm or its version it is os permission issue to resolve this you need to use below command:-
sudo chown -R $USER:$USER *
additional
sudo chmod -R 777 *
then run:-
sudo npm i
If you're trying to npm install on a folder that's being rsync'd from somewhere else, remember to add this to your rsync --exclude
yourpath/node_modules
Otherwise, NPM will try to add node_modules and rsync will remove it immediately, causing many npm WARN enoent ENOENT: no such file or directory, open errors.
Delete package.json and package-lock.json file
Then type npm init
after that type npm install socket.io --save
finally type npm install
It works for me
update version in package.json is working for me
I just experienced this error but on looking for the answer online here on stackoverflow I found the answer in the process so I decided to share it also , If this error occurs on a react project you are working on and when you run npm start make sure to change directory into the directory that has react installed in it and it will start working
if your node_modules got installed in say /home/UserName/ like in my case,
your package-lock.json file will also be there. just delete this file, go back to your app folder and run npm init and then npm install <pkgname> (e.g express) and a new node_modules folder will be created for your.
I had this in a new project on Windows. npm install had created a node_modules folder for me, but it had somehow created the folder without giving me full control over it. I gave myself full control over node_modules and node_modules\.staging and it worked after that.
Seems you have installed express in root directory.Copy path of package.json and delete package json file and node_modules folder.
I had the same problem, I resolved by removing all insignificant lines in packages.json e only left "name", "version", "description", "devDependencies", "dependencies", "resolutions". and the error was gone.
the file path you ran is wrong. So if you are working on windows, go to the correct file location with cd and rerun from there.

package.json grunt dependences modules don't show up when i do a npm install

I have created a package.json file with grunt dependencies I do my npm install but the grunt modules do not show up in my website hierarchy all I get is a bunch of warn in the terminal about different plugins that I didn't want. Also I am defiantly pointing to the right folder but it says they folder don't exist
MacBook-Pro:Taylerramsay Tayler_Ramsay$ cd ~/Desktop/taylerramsay
MacBook-Pro:taylerramsay Tayler_Ramsay$ npm install
npm WARN enoent ENOENT: no such file or directory, open '/Users/Tayler_Ramsay/package.json'
npm WARN Tayler_Ramsay No description
npm WARN Tayler_Ramsay No repository field.
npm WARN Tayler_Ramsay No README data
npm WARN Tayler_Ramsay No license field.
MacBook-Pro:taylerramsay Tayler_Ramsay$
npm tells you that there is no package.json file in your directory then it can install anything.
I recommend you to follow these step :
1. run npm init to create a valid package.json file with needed information
2. Install and save your npm modules in your package.json file with --save argument. (E.g : npm install grunt-contrib-cssmin --save)

Categories