npm - 将已安装的包保存为依赖项 [英] npm - save installed packages as dependencies

查看:51
本文介绍了npm - 将已安装的包保存为依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过 npm install $package 安装了一些软件包,而没有先设置 package.json.现在我想创建一个 package.json 文件,但保留所有已安装的包作为依赖项.简单地运行 npm init 不提供这个选项,我可以自动实现吗?

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?

推荐答案

2016 年 1 月更新

npm 现在支持开箱即用.我有 npm 版本 3.5.2.

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

只需一个 node_modules 文件夹,安装了下划线.

so with just a node_modules folder with underscore installed.

npm init --yes

然后:

cat package.json

包含在 package.json 中:

Contained within package.json:

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

这篇关于npm - 将已安装的包保存为依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆