Поиск по этому блогу

среда, 18 мая 2016 г.

Практикум с npm, читаем документацию и конспектируем как и куда устанавливаются пакеты

Сейчас мне нужен движок для статичных сайтов. Jekyll понравился, но "у него гранаты не той системы", я ведь хочу не блог вести, а менять темы (и офрмление) как перчатки, так что получается, что надо учить Ruby, дабы не путаться с "гемами" и их совместитмостью. Но я еще Nodejs толком не юзал, сейчас надо тратить время на него... Так что, ударим по бездорожью и разгильдяйству десятком ссылок на темы npm v3 Dependency Resolution, scoped package и прочее...

These are the docs you're looking for
What is a package? For example, if you create a file at node_modules/foo.js and then had a program that did var f = require('foo.js'), it would load the module. However, foo.js is not a "package" in this case, because it does not have a package.json.
npm v3 Dependency Resolution npm3 resolves dependencies differently than npm2
npm3 Duplication and Deduplication npm dedupe
npm v3 Non-determinism If you, and your development team, use a package.json, as well as the interactive npm install command to add pkgs (like most teams using npm do), it is likely that you will run into a situation where your local node_modules directory will differ from both your coworkers' node_modules directories, as well as the node_modules directories on your staging, testing, or production servers.
Installing npm packages locally
npm-developers Developer Guide


Working with scoped packages
npm-scope Scoped packages Scopes are a way of grouping related packages together, and also affect a few things about the way npm treats the package.

In [ ]:
####npm3 resolves dependencies differently than npm2
In [ ]:
F:\stradorusite\hexo\t1>npm -v
3.6.0

The key major differences are:
position in the directory structure no longer predicts the type (primary, secondary, etc) a dependency is
dependency resolution depends on install order, or the order in which things are installed will change the node_modules directory tree structure

Если не задать глубину, то не хватит места

In [ ]:
F:\stradorusite\hexo\t1>npm ls --depth=0
hexo-site@0.0.0 F:\stradorusite\hexo\t1
+-- hexo@3.2.0
+-- hexo-generator-archive@0.1.4
+-- hexo-generator-category@0.1.3
+-- hexo-generator-index@0.2.0
+-- hexo-generator-tag@0.2.0
+-- hexo-renderer-ejs@0.2.0
+-- hexo-renderer-marked@0.2.10
+-- hexo-renderer-stylus@0.3.1
`-- hexo-server@0.2.0
In [ ]:
F:\stradorusite\hexo\t1\themes\simplest>npm ls --depth=0
hexo-theme-simplest@1.1.0 F:\stradorusite\hexo\t1\themes\simplest
+-- autoprefixer@6.3.6
+-- node-sass@3.7.0
+-- postcss@5.0.21
+-- postcss-js@0.1.3
`-- uglify-js@2.6.2
In [ ]:
####Installing scoped packages

Scoped packages are installed to a sub-folder of the regular installation folder, e.g. if your other packages are installed in
node_modules/packagename, scoped modules will be in
node_modules/@myorg/packagename. The scope folder (@myorg) is simply the name of the scope preceded by an @-symbol, and can contain any number of scoped packages.

A scoped package is installed by referencing it by name, preceded by an @-symbol, in npm install:

In [ ]:
npm install @myorg/mypackage
#Or in package.json:

"dependencies": {
  "@myorg/mypackage": "^1.3.0"
}

Note that if the @-symbol is omitted in either case npm will instead attempt to install from GitHub; see npm-install.

Обновления

Найти устаревшие

In [ ]:
F:\stradorusite\hexo\t1\themes\hexo-theme-zurb-foundation>npm outdated
Package            Current  Wanted  Latest  Location
node-inspector     MISSING  0.10.2  0.12.8  hexo-theme-foundation
gulp-bower          0.0.10  0.0.10  0.0.13  hexo-theme-foundation
gulp-load-plugins   0.10.0  0.10.0   1.2.2  hexo-theme-foundation
gulp-sass            1.3.3   1.3.3   2.3.1  hexo-theme-foundation

F:\stradorusite\hexo\t1\themes\hexo-theme-zurb-foundation>
In [ ]:
#Обновить 
npm update
In [ ]:
#removes packages not depended on by your project 
#according to your package.json
npm prune


Посты чуть ниже также могут вас заинтересовать

Комментариев нет: