Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've installed some packages via npm install $package, without setting up a package.json first. Now I would like to create a package.json file, but keep all installed packages as dependencies. Simply running npm init doesn't offer this option, can I achieve this automatically?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
319 views
Welcome To Ask or Share your Answers For Others

1 Answer

Update January 2016

npm now supports this out of the box. I have npm version 3.5.2.

so with just a node_modules folder with underscore installed.

npm init --yes

then:

cat package.json

Contained within package.json:

"dependencies": {
    "underscore": "^1.8.3"
  },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...