gawel / gp.recipe.node

ZC Buildout recipe for node.js
11 stars 10 forks source link

Is pinning of pulled in npm package dependencies possible? #23

Closed fredvd closed 2 years ago

fredvd commented 9 years ago

The documentation mentions that you can pin node packages by specifying npmname@version in the recipe's npm = variable.

but what about packages that get pulled in by the packages listed in the recipe? For example with installing grutn you get the dependency tree below:

grunt@0.4.5 /Users/fred/buildouts/vmm-nieuw/parts/node/lib/node_modules/grunt +-- which@1.0.9 +-- dateformat@1.0.2-1.2.3 +-- eventemitter2@0.4.14 +-- getobject@0.1.0 +-- rimraf@2.2.8 +-- colors@0.6.2 +-- async@0.1.22 +-- hooker@0.2.3 +-- grunt-legacy-util@0.2.0 +-- nopt@1.0.10 (abbrev@1.0.6) +-- exit@0.1.2 +-- lodash@0.9.2 +-- minimatch@0.2.14 (sigmund@1.0.1, lru-cache@2.6.4) +-- glob@3.1.21 (inherits@1.0.0, graceful-fs@1.2.3) +-- coffee-script@1.3.3 +-- underscore.string@2.2.1 +-- iconv-lite@0.2.11 +-- js-yaml@2.0.5 (argparse@0.1.16, esprima@1.0.4) +-- grunt-legacy-log@0.1.2 (grunt-legacy-log-utils@0.1.1, underscore.string@2.3.3, lodash@2.4.2) `-- findup-sync@0.1.3 (glob@3.2.11, lodash@2.4.2)

npm supports the 'shrinkwrap' option to dump a full depth versionslist of all pulled in packages, but running this with gp.recipe.node's /bin/inpm shrinkwrap I get an empty npm-shrinkwrap.json. If and how are other users of this recipe doing this?

gawel commented 9 years ago

I think that the problem is that I use parts/node-buildout as $HOME during installation to have a correct .npmrc Maybe the $HOME should be replaced when running the bin/npm script too

You can try with HOME=parts/buildout-node bin/npm shrinkwrap and see if it helps

fredvd commented 9 years ago

No this does not seem to help. buildout-node does not contain an .npmrc, but parts/node does. It's contents is however:

prefix=/Users/fred/buildoutst/npmtest/parts/node
cache=/Users/fred/.npm
color=false
unicode=false

either paths (node or buildout-node) don't help setting as a HOME for bin/npm:

fred@tycho.local:nodetest (svn:trunk+?) $ HOME=/Users/fred/buildouts/nodetest/parts/buildout-node/ bin/npm shrinkwrap
npm ERR! Darwin 14.3.0
npm ERR! argv "/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/bin/node" "/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/bin/npm" "shrinkwrap"
npm ERR! node v0.12.3
npm ERR! npm  v2.9.1

npm ERR! Problems were encountered
npm ERR! Please correct and try again.
npm ERR! extraneous: dependency-check@2.4.0 /Users/fred/buildouts/nodetest/node_modules/dependency-check
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/fred/buildouts/nodetest/npm-debug.log
fred@tycho.local:nodetest (svn:trunk+?) $ HOME=/Users/fred/buildouts/nodetest/parts/node/ bin/npm shrinkwrap
npm ERR! Darwin 14.3.0
npm ERR! argv "/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/bin/node" "/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/bin/npm" "shrinkwrap"
npm ERR! node v0.12.3
npm ERR! npm  v2.9.1

npm ERR! Problems were encountered
npm ERR! Please correct and try again.
npm ERR! extraneous: dependency-check@2.4.0 /Users/fred/buildouts/nodetest/node_modules/dependency-check
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/fred/buildouts/nodetest/npm-debug.log

The npm-debug.log isn't very verbose either....

'''' 0 info it worked if it ends with ok 1 verbose cli [ '/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/bin/node', 1 verbose cli '/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/bin/npm', 1 verbose cli 'shrinkwrap' ] 2 info using npm@2.9.1 3 info using node@v0.12.3 4 verbose stack Error: Problems were encountered 4 verbose stack Please correct and try again. 4 verbose stack extraneous: dependency-check@2.4.0 /Users/fred/buildouts/nodetest/nodemodules/dependency-check 4 verbose stack at shrinkwrap (/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/lib/node_modules/npm/lib/shrinkwrap.js:37:15) 4 verbose stack at /Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/lib/node_modules/npm/lib/shrinkwrap.js:31:5 4 verbose stack at /Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/lib/node_modules/npm/lib/ls.js:47:30 4 verbose stack at /Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/lib/node_modules/npm/node_modules/read-installed/read-installed.js:138:5 4 verbose stack at /Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/lib/node_modules/npm/node_modules/read-installed/read-installed.js:251:14 4 verbose stack at cb (/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24) 4 verbose stack at /Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/lib/node_modules/npm/node_modules/read-installed/read-installed.js:251:14 4 verbose stack at cb (/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24) 4 verbose stack at /Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/lib/node_modules/npm/node_modules/read-installed/read-installed.js:251:14 4 verbose stack at cb (/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24) 5 verbose cwd /Users/fred/buildouts/nodetest 6 error Darwin 14.3.0 7 error argv "/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/bin/node" "/Users/fred/buildouts/nodetest/parts/buildout-node/node-v0.12.3-darwin-x64/bin/npm" "shrinkwrap" 8 error node v0.12.3 9 error npm v2.9.1 10 error Problems were encountered 10 error Please correct and try again. 10 error extraneous: dependency-check@2.4.0 /Users/fred/buildouts/nodetest/node_modules/dependency-check 11 error If you need help, you may report this error at: 11 error https://github.com/npm/npm/issues 12 verbose exit [ 1, true ]

reinout commented 9 years ago

How big is the problem? I assume that "npm install grunt" just works. Same with bower. I assume that such basic pieces of functionality will install properly without problems.

We normally then use bower to download the rest. With a bower.json including version pins. (Executed automatically via a collective.recipe.cmd buildout part).

So: maybe a mixed buildout/bower approach might work.

gawel commented 9 years ago

The problem exist because packages are installed with the -g option. I guess nobody use that in the js world. If you install packages by hand with npm install then shrinkwrap seems to work

You can also use:

HOME=$PWD/parts/node ./bin/npm -g shrinkwrap

iif you have a package.json in parts/node ... If someone know why... let me know.

Notice that recent versions of this recipe support package.json. You just need to add "." in the dependencie list. You have to list dependencies as dependencies. devDependencies will not work... Yet another weird effect.

I'm usualy using something like this:

[node]
recipe = gp.recipe.node
npms =
    gulp
    bower
    .

I'm adding gulp/bower so the recipe will create the binaries in bin/ for those packages.

sallner commented 2 years ago

I added some documentation about using package.json in #37 .