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

查看:79
本文介绍了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天全站免登陆