I have created an npm package which has a lot of dependencies, but when I test my app with npm install -g ./ the app gets added in the global npm directory but without the node-modules folder. Thus when the app is run through the terminal, although the app is recognized, it doesn't work because none of the dependency is installed.
How can I make sure to make app installs node-modules when its published in the npm registry
If I install the node-modules independently on the project folder by doing npm install, the app works. I don't want the user to install the packages independently. What I am expecting is the full installation of the app and the required dependencies only with npm install -g my_package
I have also used yarn as the package manager, and the dependencies are listed under "dependencies" in package.json file. The "bin" field in the package.json file points to our app, which can also be run as node bin/index.js. This app is also recognized by the terminal, the only problem is the dependencies
I think you can use this command npm install --save then it might work.
When I npm install package, npm says that it successfully installed the package, but when I look for it in the node_modules folder, the package is not in the folder. When I npm install -g package, the package gets installed into the global /node_modules folder, so I have to drag the package from the global folder to the local folder.
Why is npm install not installing into my local /node_modules folder?
step 1) rm -rf ./node_modules from your root directory.
step 2) npm install.
The above commands first deletes your node_modules and then reinstalls all the packages that are found inside your package.json.
This is the same problem I was facing, both the above commands resolved the problem in my case.
If the above solution does not work in your case :
The problem is :
Data is not being fetched from the package.json, you must check whether you have written the correct statement or not inside your package.json.
There are a few things you can do to resolve this problem, as mentioned here.
First, try deleting your package-lock.json file. If you run npm install or npm i after that it should generate a brand new installation with no reference to an existing package-lock.json file.
If that doesn't work, try deleting your node_modules directory in your project. Then run npm install or npm i.
If THAT doesn't work, you should try deleting both the node_modules directory AND the package-lock.json. Then run npm install or npm i. This should resolve the issue.
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.
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)
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.