Questions tagged [package.json]

All npm packages contain a file, usually in the project root, called package.json. This file holds various metadata relevant to the project. This file is used to give information to npm that allows it to identify the project as well as handle the project's dependencies.

All npm packages contain a file, usually in the project root, called package.json. This file holds various metadata relevant to the project. This file is used to give information to npm that allows it to identify the project as well as handle the project's dependencies.

It can also contain other metadata such as a project description, the version of the project in a particular distribution, license information, even configuration data, all of which can be vital to both and to the end users of the package. The file is normally located at the root directory of a project.

{
  "name" : "express",
  "version" : "0.0.0",
}

The name field is the name of your project. The version field is used by to make sure the right version of the package is being installed. Generally, it takes the form of major.minor.patch where major, minor, and patch are integers which increase after each new release.

For more details see the package.json documentation at npmjs.com.

3428 questions
244
votes
2 answers

What is purpose of the property "private" in package.json?

I'm learning node.js and express, I am wondering what is the property "private" in ./package.json file used for?
CarlLee
  • 3,952
  • 5
  • 23
  • 33
202
votes
4 answers

What should I put in the license field of package.json if my code is only for use by the company I work for?

NPM 2.11.3 I'm building a library in Node. This library is only for use by the company I am currently working for. I think this means that the license is "None". But when I npm init it wants me to use an SPDX License. "None" or "Unlicensed" are not…
jcollum
  • 43,623
  • 55
  • 191
  • 321
198
votes
13 answers

"unexpected token import" in Nodejs5 and babel?

In js file, i used import to instead of require import co from 'co'; And tried to run it directly by nodejs since it said import is 'shipping features' and support without any runtime flag (https://nodejs.org/en/docs/es6/), but i got an…
johugz
  • 2,023
  • 2
  • 13
  • 9
192
votes
2 answers

What is the "module" package.json field for?

I've seen some npm packages (vue for example) have a module field in their package.json. But module is not included in the package.json documentation - is this a convention of some kind? Is there documentation for this somewhere?
ryanve
  • 50,076
  • 30
  • 102
  • 137
184
votes
13 answers

Module not found: Error: Can't resolve 'core-js/es6'

I've got a problem with my build process in relation to my React app. I always get the following error: Module not found: Error: Can't resolve 'core-js/es6' if I use this in a polyfill.js: import 'core-js/es6'; That is my package.json: { …
Gutelaunetyp
  • 2,144
  • 4
  • 15
  • 40
167
votes
16 answers

How to npm publish specific folder but as package root

I have a project that include a gulp task for building and packaging the sources and release in a directory called dist. My goal is publish it as a npm package, but only my dist folder. The npm documentation says that I can use the files tag to…
robsonrosa
  • 2,548
  • 5
  • 23
  • 31
166
votes
10 answers

How do I fix a vulnerable npm package in my package-lock.json that isn't listed in the package.json?

Github is telling me that a dependency in my package-lock.json file is vulnerable and outdated. The problem is that if I do npm install or npm update, neither of them update the dependency in the package-lock.json file. I've done a lot of googling…
Raph117
  • 3,441
  • 7
  • 29
  • 50
163
votes
7 answers

How to install only "devDependencies" using npm

I am trying to install ONLY the "devDependencies" listed in my package.json file. But none of the following commands work as I expect. All of the following commands install the production dependencies also which I do not want. npm install --dev npm…
Nesan Rajendran
  • 1,653
  • 2
  • 12
  • 7
160
votes
5 answers

npm equivalent of yarn resolutions?

Is there an npm equivalent of the yarn resolutions functionality? There is no mention of it in the npm package.json docs. For example, I want to install lerna@3.3.2 and one of its dependencies (@lerna/publish) at 3.3.2 as well. Currently doing that…
adanilev
  • 3,008
  • 3
  • 15
  • 20
159
votes
25 answers

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in the package.json of a module in node_modules

This is a React web app. When I run npm start This error occurred > dataflow@0.1.0 start > react-scripts start node:internal/modules/cjs/loader:488 throw e; ^ Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not…
Julian Chu
  • 1,790
  • 2
  • 7
  • 12
128
votes
7 answers

npm update does not do anything

When I execute this code in my application folder where the package.json is located: npm update or npm update --save-dev it does not do anything. But when I do npm outdated is shows many outdated packages. So how do I update all packages? OS: Win 10…
Elisabeth
  • 20,496
  • 52
  • 200
  • 321
118
votes
50 answers

Error: EPERM: operation not permitted, unlink 'D:\Sources\**\node_modules\fsevents\node_modules\abbrev\package.json'

I just updated npm to 5.4.0. Now, Whenever I want install a npm package I get the following error: D:\Sources\DownloadCms\Md.Download\Web.Angular>npm install mds.angular.datetimepicker@latest --save npm ERR! path…
Mohammad Dayyan
  • 21,578
  • 41
  • 164
  • 232
117
votes
10 answers

How to use environment variables in package.json

Because we don't want sensitive data in the project code, including the package.json file, using environment variables would be a logical choice in my opinion. Example package.json: "dependencies": { "accounting": "~0.4.0", "async":…
kaasdude
  • 1,336
  • 2
  • 8
  • 13
113
votes
2 answers

What is the significance of browserslist in package.json created by create-react-app

I was asked this in an interview. I could not answer. "browserslist": [ ">0.2%", "not dead", "not ie <= 11", "not op_mini all" ] I can see that Its an array. "not ie <=11" means will not run on lower than Internet Explorer v11 "op_mini" must be…
Tanzeel
  • 4,174
  • 13
  • 57
  • 110
113
votes
2 answers

How to specify the path of `package.json` to npm?

I use npm scripts to build my project. I'd like to be able to run the scripts from a different directory. That is, instead of doing the following: cd project; npm run build; cd .. ...I'd like to simply do something like: npm run build -config…
rinogo
  • 8,491
  • 12
  • 61
  • 102