First time user of npm and bower. I am able to install packages correctly but I am not sure how the dependencies work? As an example, I did "npm install angularjs" in my application root which created a folder "node_modules/angularjs/" with some files in it. I can also see that there is a package.json file within the angularjs folder, and it looks like it has not been processed as there is numerous packages listed in it and not installed.
npm和bower的首次使用者。我能够正确安装软件包,但我不确定依赖项是如何工作的?作为一个例子,我在我的应用程序根目录中执行了“npm install angularjs”,它创建了一个文件夹“node_modules / angularjs /”,其中包含一些文件。我还可以看到angularjs文件夹中有一个package.json文件,看起来它没有被处理,因为它中列出了许多软件包而没有安装。
Long story short, should I install all these packages manually or is there a built in feature that npm/bower can also process these sets of dependencies?
简而言之,我应该手动安装所有这些软件包还是有内置功能,npm / bower也可以处理这些依赖项集?
UPDATE:
I greatly lack the ability to ask precise questions, I apologise to those who have answered and did not give the correct sypnosis.
我非常缺乏提出精确问题的能力,我向那些已经回答并且未给出正确症状的人道歉。
What I expect to happen:
我期待发生的事情:
Using npm or bower, I want to clarify that if I do an install of one of their packages, will it automatically also install the new package's dependancies or would I need to do a npm/bower install for each of the packages.json or bower.json files manually?
使用npm或bower,我想澄清一下,如果我安装了其中一个软件包,它是否会自动安装新软件包的依赖项,或者我需要为每个package.json或bower安装npm / bower手动.json文件?
What I did to try make it work:
我做了什么尝试让它工作:
- Created folder D:\Websites\TestSite
- Within the folder through CMD, I did a "npm init" and ran through the guide
- I followed that up with a "npm install angularjs"
- A new folder was created D:\Websites\TestSite\node_modules\angularjs and within this folder there was a "index.js" and package.json file
- Opening index.js I get a "require("angular");" and module.exports = window.angular.
- The package.json file contains a number of dependancies which has not been installed.
创建文件夹D:\ Websites \ TestSite
在通过CMD的文件夹中,我做了一个“npm init”并浏览了指南
我跟着一个“npm install angularjs”
创建了一个新文件夹D:\ Websites \ TestSite \ node_modules \ angularjs,在此文件夹中有一个“index.js”和package.json文件
打开index.js我得到一个“require(”angular“);”和module.exports = window.angular。
package.json文件包含许多尚未安装的依赖项。
My Result:
- As per my expectations, npm install in point 3 above did not install the dependancies of the package.json file after it installed angularjs.
- I am not sure but I assume that the index.js file needs to be included in my html and that it required the requirejs library initiated? If this is the case, then requirejs (which I do not have installed on my site) should be a dependancy for angularjs to work, and should be installed prior to giving me the ability to try and initiate it?
- Am I missing a step or misunderstanding the functionality of NPM/Bower? Thank you for your patience!
根据我的预期,上面第3点中的npm install在安装angularjs之后没有安装package.json文件的dependancies。
我不确定,但我认为index.js文件需要包含在我的html中,并且需要启动requirejs库?如果是这种情况,那么requirejs(我在我的网站上没有安装)应该是angularjs的工作依赖,应该在让我尝试启动它之前安装吗?
我错过了一步还是误解了NPM / Bower的功能?感谢您的耐心等待!
1 个解决方案
#1
2
Npm
and Bower
are great tools for managing your dependencies, i'll try to make it clear in a few words.
Npm和Bower是管理依赖关系的绝佳工具,我会试着用几句话来说清楚。
In general npm
is used for managing your back-end dependencies and Bower
is responsible for your front end dependencies.
通常,npm用于管理后端依赖项,Bower负责前端依赖项。
There are 2 config files:
有2个配置文件:
-
package.json
, here are listed your dependencies that are not used in browser(e.g. bower, grunt). To install all dependencies in package.json runnpm install
. -
Bower.json
, here will be listed your "in browser" dependencies(e.g angular, jQuery). Runbower install
to install all dependencies listed here in bower_components
package.json,这里列出了你在浏览器中没有使用的依赖项(例如bower,grunt)。要在package.json中安装所有依赖项,请运行npm install。
Bower.json,这里将列出你的“浏览器”依赖项(例如angular,jQuery)。运行bower install以安装bower_components中列出的所有依赖项
You can find a extended guide i wrote here.
你可以找到我在这里写的扩展指南。
#1
2
Npm
and Bower
are great tools for managing your dependencies, i'll try to make it clear in a few words.
Npm和Bower是管理依赖关系的绝佳工具,我会试着用几句话来说清楚。
In general npm
is used for managing your back-end dependencies and Bower
is responsible for your front end dependencies.
通常,npm用于管理后端依赖项,Bower负责前端依赖项。
There are 2 config files:
有2个配置文件:
-
package.json
, here are listed your dependencies that are not used in browser(e.g. bower, grunt). To install all dependencies in package.json runnpm install
. -
Bower.json
, here will be listed your "in browser" dependencies(e.g angular, jQuery). Runbower install
to install all dependencies listed here in bower_components
package.json,这里列出了你在浏览器中没有使用的依赖项(例如bower,grunt)。要在package.json中安装所有依赖项,请运行npm install。
Bower.json,这里将列出你的“浏览器”依赖项(例如angular,jQuery)。运行bower install以安装bower_components中列出的所有依赖项
You can find a extended guide i wrote here.
你可以找到我在这里写的扩展指南。