NPM still looking for deleted dependency - npm

I deleted some module folders that I had previously npm installed into a module. I also manually removed their entries in my module's package.json. Then, npm would still look for those deleted folders so I re-created the folders and npm uninstalled them, which succeeded. Is there another way to "clear" npm's graph?

Try running npm cache clean --force and then see if the problem still persists. S If would help if you posted your package.json file so that we could see if any problems exist.

Related

Yarn lock file resource source changed from registry.yarnpkg.com to registry.npmjs.org

I recently npm installed a package into my Ruby on Rails application. The installation changed my yarn.lock file. Specifically, the "resolved" field for all my resources have changed from yarnpkg.com to npmjs.org.
From this:
d3-dsv#1:
version "..."
resolved "https://registry.yarnpkg.com/d3-dsv/-/d3-dsv-1.0.8.tgz#..."
integrity ...
To this:
"d3-dsv#1":
"integrity" "..."
"resolved" "https://registry.npmjs.org/d3-dsv/-/d3-dsv-1.1.1.tgz"
"version" "..."
Is there a problem with these changes in this yark.lock file? Should I have done some yarn alternate to npm installing?
You can fix this issue by re-running yarn again.
To accomplish this, follow the steps below.
Remove the registry.npmjs.org section in your yarn.lock file.
Run the yarn command again.
$ yarn
This should rewrite the yarn.lock to change the registry from npm to Yarn.
The steps above should rewrite the yarn.lock file, and change the registry and text from npm to Yarn.
If you are using only public packages in your application then this will not cause many problems. You can go about your business as it is.Although there might be some complications when you authenticate for any of them at any point.
If you are using any private repositories, you have to re-register your packages with yarn and add credentials to them.
The following steps will help you.
Setup a private repo on npmjs.org and add a scope and your package (Lets name it boo)
Create a new project locally and upload it to the npm registry (let's call it blimp)
So when they are updated it will be #boo/blimp
Add the package to your new applications package.json by installing yarn add #boo/blimp
Remove the node_modules (rm -rf node_modules)
Try yarn install if there is an error in the lock file try re-creating one as follows
sed -ie 's,registry.yarnpkg.com/#boo,registry.npmjs.org/#boo,' yarn.lock
7. If that omits an issue like Request failed or something in that alley, try following
yarn config set registry https://registry.npmjs.org
At this point, you have tried lots of options. If this is still an issue in your system then you might have to move to `npm` package management. Follow the [yarn][2] repository for more updates.
Similar issues
yarn.lock should not include base registry
Support protocol-relative registry
Support for registry URLs without trailing slash
I suspect this happened to me because I installed something with npm install instead of yarn. I recognized my mistake, npm uninstalled the package, then yarn added the package, but then every entry in yarn.lock was changed to use npmjs.org instead of yarnpkg.com.
I did not commit the changes to source control, and the problem disappeared after I...
Deleted package-lock.json
Reverted the change to package.json in source control (i.e. removed the new package)
Reverted all changes to yarn.lock in source control
yarn added the package again
I am unsure if using npm install followed by yarn add is really what triggered the problem. Can anyone confirm?

How to prevent npm install removes local added packages

Looked to numerous SO questions and answers, however have not found the answer to fix the following issue.
On my local machine I run npm from the folder node_modules. This folder contains several packages from GIT-sources, however there are two folders containing custom made scripts. Each time I update package with npm install my two custom folders are gone. Luckily I made a backup and was able to restore these two. But it's also annoying, because what else is removed that I don't see??
I'm on npm version 6.13.2
Any help is of course highly appreciated.
There is no way you can prevent npm from removing those folders because they are not in your package.json.
Although there are two things that you can do which are as follows,
Create npm modules for those 2 scripts and update their entries in your package.json. Here is a link for 'how to create and publish node module'.
https://www.guru99.com/node-js-modules-create-publish.html
Create a repo for those 2 scripts and update their git paths in your package.json.

Cannot find module 'lodash/isEmpty'

Got an error after doing npm start
Error:- https://gist.github.com/anonymous/72b80088aca1e939da5760bee6b39570
Things I did:-
1- I removed lodash folder from node_modules folder, then I cleared the cache using npm cache clear. After that I did npm install, as lodash was present in package.json. But I am getting the same error
2- Then used node version 8.0.0, got same error
3- I've used 'require' to import lodash/isEmpty. So, I don't there is any spelling mistake.
4- I've already checked the presence of isEmpty.js file inside lodash folder, under node_modules directory. And it's there.
Update:- I removed the node_module folder and then I removed the cache using npm cache clean. After that I did npm install. But I am still getting the same error.

Deleting project folder

Let's say i want to delete project folders with a bunch of localy installed npm packages such as gulp, gulp-sass or/and other package managers maybe bower with it's own packages.
Is it an easier way to just manualy shift+del whole folder and, well, I don't know, don't leave behind some conflicts or something?
Or maybe npm has a command to proper uninstall all packages, "uninit" folder, etc?
I got this problem.
At first, I copied all of packages from packages.json and run command like:
npm uninstall #typescript-eslint/eslint-plugin #typescript-eslint/parser #vue/cli-plugin-babel #vue/cli-plugin-eslint (... etc.) --save
Then, I tried to delete folder by hands, but it is deny permitions.
I open my project from VSCode and delete node_modules from tree by hands:
Delete node_modules from tree by hands from VSCode
It was delete successfully!
p.s.: The remaining files are deleted without problems manually...

Does npm delete downloaded module if the installation fails?

When I try to install something with npm it fails quite often (much more often that apt-get for example), and it will display "see log file for details" or "make in the directory failed". But when I try to inspect the directory said it will not be found. Does NPM simply delete every thing it just downloaded if anything fails during installation? Why would it tell me to check the directory then if it deleted it?
npm keeps downloaded packages as tarballs inside a cache folder.
see: https://www.npmjs.org/doc/cli/npm-cache.html
When you run npm install and something goes wrong, it will try to undo and remove the packages from your current location, but it should leave the cached tarballs alone. Sometimes the cache can have a bad package-tarball.
You can force npm to install without using the cache like this npm install --force. Or, if you really must, you can clear out the whole cache like this npm cache clean.
Remember: npm installs packages into the current folder, or wherever your package.json can be found