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.

Filter by
Sorted by
Tagged with
4432votes
19answers
1.2mviews

What's the difference between tilde(~) and caret(^) in package.json?

After I upgraded to the latest stable node and npm, I tried npm install moment --save. It saves the entry in the package.json with the caret ^ prefix. Previously, it was a tilde ~ prefix. Why are ...
user avatar
  • 78.7k
2530votes
17answers
740kviews

What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?

This documentation answers my question very poorly. I didn't understand those explanations. Can someone say in simpler words? Maybe with examples if it's hard to choose simple words? EDIT also added ...
user avatar
772votes
27answers
389kviews

Is there a way to get version from package.json in nodejs code?

Is there a way to get the version set in package.json in a nodejs app? I would want something like this var port = process.env.PORT || 3000 app.listen port console.log "Express server listening on ...
user avatar
482votes
18answers
680kviews

How to set environment variables from within package.json?

How to set some environment variables from within package.json to be used with npm start like commands? Here's what I currently have in my package.json: { ... "scripts": { "help": "tagove ...
user avatar
  • 7,324
414votes
11answers
189kviews

Find unused npm packages in package.json

Is there a way to determine if you have packages in your package.json file that are no longer needed? For instance, when trying out a package and later commenting or deleting code, but forgetting to ...
user avatar
  • 5,451
407votes
30answers
854kviews

SyntaxError: Cannot use import statement outside a module

I've got an ApolloServer project that's giving me trouble, so I thought I might update it and ran into issues when using the latest Babel. My "index.js" is: require('dotenv').config() import ...
user avatar
  • 4,613
372votes
26answers
998kviews

Start script missing error when running npm start

I'm receiving this error when trying to debug my node application using the npm start command. Error: npm ERR! Windows_NT 6.3.9600 npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "...
user avatar
  • 4,293
367votes
3answers
86kviews

How do I decide whether @types/* goes into `dependencies` or `devDependencies`?

I use TypeScript 2 in my project. I'd like to use some js library, but also typings for that library. I can install types with simple npm install @types/some-library. I'm not sure if I should --save ...
user avatar
  • 4,858
264votes
13answers
261kviews

npm install private github repositories by dependency in package.json

I'm trying to install github private repository by npm that includes other private github repositories as dependency. Have tried a lot of ways and posts but none is working. Here is what i'm doing : ...
user avatar
251votes
6answers
137kviews

How to use private Github repo as npm dependency

How do I list a private Github repo as a "dependency" in package.json? I tried npm's Github URLs syntaxes like ryanve/example, but doing npm install in the package folder gives "could not install" ...
user avatar
  • 46.2k
250votes
7answers
77kviews

Move a module from devDependencies to dependencies in npm package.json

Is there any short command to move a module from devDependencies to dependencies in package.json? I find myself always doing this: npm uninstall <module_name> --save-dev npm install <...
user avatar
  • 5,032
235votes
5answers
128kviews

Do I need both package-lock.json and package.json?

After updating my NPM to the latest version (from 3.X to 5.2.0) and running npm install on an existing project, I get an auto-created package-lock.json file. I can tell package-lock.json gives me an ...
user avatar
  • 3,549
232votes
7answers
258kviews

How do I add a custom script to my package.json file that runs a javascript file?

I want to be able to execute the command script1 in a project directory that will run node script1.js. script1.js is a file in the same directory. The command needs to be specific to the project ...
user avatar
  • 2,926
232votes
26answers
305kviews

Field 'browser' doesn't contain a valid alias configuration

I've started using webpack2 (to be precise, v2.3.2) and after re-creating my config I keep running into an issue I can't seem to solve I get (sorry in advance for ugly dump): ERROR in ./src/main.js ...
user avatar
214votes
2answers
68kviews

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?
user avatar
  • 3,632

15 30 50 per page
1
2 3 4 5
183