npm install but in package-lock, npmjs changes to yarnpkg - node.js

What I did:
Git pull from main
run nvm use to use node v14.17.6 (npm v6.14.15) then npm install
delete package-lock.json then run npm install again
After steps 2 and 3, for some dependencies package-lock.json, npmjs changed to yarnpkg.
Questions:
Why did this happen since this project does not use yarn
How can I fix this

try this -
npm cache clear - -force
npx rimraf ./**/node_modules
del package-lock.json
now run npm install again

Related

npm install does not work in my angular project

Why npm install does not work perfectly. When i create a new angular project and copy and paste the "src" file there, npm install works. But when I copy-paste the "package.json" same as src, npm install does not work.
This error is mentioned in the nodemon documentation:
If you see the error Cannot find module 'internal/util/types', the
error is solved with a clean npm cache and trying to reinstall the
dependency you're working with.
A start is to use the following commands:
sudo npm cache clean --force
sudo npm i -g npm
You have some missing modules in node_modules folder.
try to install with auto-install.
first install the global-cli by cmd npm install -g auto-install
then run auto-install in the directory you are working in.

installing node but missing all packages in node_modules

On the Mac, after installing node with:
brew install node
The only package that showed up in /usr/local/lib/node_modules is npm. My previous installation of node contained a bunch of packages such "express, apn, http2, ws, etc."
Any ideas?
There was not a package.json either.
When you install node you only get npm, those other packages you mention, were installed using
# probably with sudo
npm install -g {package}
The package.json is created when you run:
npm init
It has nothing to do with node installation.
If you wish to start a new project:
mkdir project
cd project
npm init
npm install {package-name} {other-package}
And now you will have a node_modules folder inside project/ and a package.json with {package-name} & {other-package} as dependencies

Managing node modules in npm5

I'm still using node v6 and npm v3 and planning to move to node v8 and npm v5
I use npm in client(Angular2) and server side(Express)
These are the steps i follow to manage node modules in
npm v3
to save in package.json and update npm-shrinkwrap.json
npm install packagename#version --save
to save in package.json dependency and not to update npm-shrinkwrap.json
npm install packagename#version --save-dev
npm install will install dependency and dependencies but will not update npm-shrinkwrap.json file
npm run build builds front end code using webpack
npm prune --production removes all devDependencies after the build process and will not update npm-shrinkwrap.json file
What i'm facing in
npm 5.4.2
npm install installs modules and updatespackage-lock.json with dependency and devDependencies if any change in version
npm run build builds front end code using webpack
npm prune --production removes all devDependencies from node_modules and package-lock.json
How we can enforce keeping dependency alone in package-lock.json ?
Any other recommendations on build process ?
Should we keep devDependencies in node_modules if its not used in production?
------ Update on 10/25/2017 -------
To remove devDependencies without updating package-lock.json
try npm prune --production --no-package-lock

Gulp install globally

I need install gulp. I used this command: npm install gulp gulp-plumber gulp-sass gulp-autoprefixer gulp-concat gulp-uglify gulp-notify
Unfortunelly in my project It was created node_modules directory. How do I do this? I don't have to add files in any project. I would like to use only command "gulp watch".
add -g for global installing
$ npm install -g gulp
OR
$ sudo npm install -g gulp
To install a npm package globally on a machine, use one of
npm i -g <packages>
npm install --global <packages>
However, this doesn't let anybody else know about this dependency. Consider instead adding node_modules/ to your .gitignore file (or the ignore of whatever VCS you are using), then install with
npm i --save-dev <packages>
The --save-dev here means that it knows that this dependency is only for development and not required in deployment. So if you use a script to deploy which installs the npm dependencies, you can have it ignore these packages
Add gulp in your package.json and run npm intall from your project directory.

What NPM command should users run if the package.json file has been updated?

If I update the package.json file in an NPM workflow app, what command do existing users run to update their local node_modules dependencies?
To start using it, they run:
$ npm install
So what do they run if there is a change to the package.json file? Or do they just delete the folder and re-run the npm install command?
To re-validate the package.json and install adjusted versions or new packages:
$ npm install
The one thing this won't do is remove packages that aren't in package.json. To do that, run:
$ npm prune
If you've only changed package versions and not added new packages:
$ npm update
If you you've updated a specific package version:
$ npm update {packagename}
You should either do
npm install && npm prune
or
npm upgrade && npm prune
npm install will be faster than npm upgrade because it only updates packages in node_modules if package.json demands a newer version. npm uprade, on the other hand, will download updates to dependencies if they are available, which may include bug fixes. For ≥npm-5, you should use npm install because npm upgrade will have the side-effect of modifying any package-lock.json file which should not be modified unless if you are the package’s maintainer.
npm prune is necessary because the updates to package.json may have removed dependencies. If you do not run npm prune, packages installed by a prior version of package.json will remain in the node_modules directory that would not be there if you freshly downloaded/cloned the project and ran npm install. Due to how some packages conditionally call require() or even scan the node_modules directory, leaving packages which were removed from package.json can result in unexpected behavior.

Resources