Does the package.json file have a unique name for each site when used in local dev?

I am new to npm and have set up a test site on my local dev server. Now I want to install a new project in a different local directory with the same dependencies as the test site by copying the package.json file from the test site to the new project and running the npm install.

If the name in the test site is the package.json file, for example "npm-site-build", can I use the same name in the new project.json file of the project? Or should the name be unique for each project?

The docs on npmjs.com say:

The name and version together form an identifier that is considered completely unique.

I'm guessing this is only for packages that are meant to be published to npm?

+3


source to share


1 answer


You're right. The name given in package.json

must be unique if you run npm publish

to publish your package to the npm registry. Otherwise, these two directories will not know each other and may have the same files package.json

. Npm doesn't keep track of all projects on your machine, only packages in the registry.



+1


source







All Articles