3

I am deploying my node.js app to Appfog but since their install script cannot parse npm-shrinkwrap.json the whole deploy process fails.

An example dependency in shrinkwrap.json today looks like this

   "async": {
      "version": "0.2.10",
      "from": "async@0.2.10", <--- This line breaks install script at appfog
      "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz"
    },

I went through the whole shrinkwrap file and removed the "from" part from each dependency declaration and i managed to upload my application, and it works.

So my question is , how do i use an older version of npm shrinkwrap so i can get the version of shrinkwrap.json that i need?

Appfog support told me i need to use version 1.1.21 but i have not succeeded in installing it.

Please ask if some info is missing.

Kimpo
  • 5,835
  • 4
  • 26
  • 30
  • In your package.json if you specify the exact version that you want to install, do you still need shrinkwrap? – Purefan May 04 '14 at 19:42

3 Answers3

1

Try this:

npm install https://github.com/npm/npm/archive/v1.1.21.tar.gz
node ./node_modules/npm/bin/npm-cli.js shrinkwrap
sakai
  • 163
  • 7
  • i get "Error: npm doesn't work with node v0.10.26" , does it mean that i have to install another version of node aswell? – Kimpo May 04 '14 at 11:43
  • Yes, to use that npm version, you will have to install another version of node somewhere. You could install it in a different directory and refer to that node specifically when doing this to keep your default node. [n](https://www.npmjs.org/package/n) suggested by @hereandnow78 seems to be an easy way to do that. – sakai May 05 '14 at 13:38
1

if you just want to use an older version of npm, you can install it via npm (i know that sounds strange, but its possible)

npm install npm@1.1.21

edit: so you try to install a version of npm which does not exist. just run

npm view npm

and take a look at the property version, to see which versions you could install via npm.

you will see that 1.1.21 does not exist in the registry, which means that you should try to install it via github (see answer by @sakai).

but then you see the next problem. you are using node@0.10.26, and npm 1.1.21 is probably not compatible with node@0.10.x.

so i for myself see basically 2 possible solutions:

Solution 1:

use n (or maybe nvm for switching node-versions back and forth. you could try to install a node@0.8.x version and try to install npm@1.1.21 there, and when done with shrinkwrapping switch back to your current node version.

Solution 2

you could setup some kind of grunt/gulp-task (i hope you use one of them) to run grunt/gulp shrinkwrap, which generates your shrinkwrap.json (via npm shrinkwrap) and when done cleans up your shrinkwrap.json

hereandnow78
  • 14,094
  • 8
  • 42
  • 48
  • i get "Error: version not found: npm@1.1.21" – Kimpo May 04 '14 at 11:39
  • see my edit, even if i do not understand why appfog would force you to use such an old npm-version. according to this https://docs.appfog.com/languages/node#node-dep-mgmt it should just work... – hereandnow78 May 04 '14 at 19:43
  • I kinda went with solution 2 and just wrote a small script that removes "from" lines from the file, which feels a bit hackish. I should probably just switch to a proper hosting. – Kimpo May 06 '14 at 07:46
1

Another—possibly simpler—solution is to just include node_modules into your repo.

Related: Should I check in node_modules to git when creating a node.js app on Heroku?

Community
  • 1
  • 1
Kostia
  • 6,284
  • 1
  • 18
  • 15
  • 1
    I tried this, Appfogs ruby gems throws an error "No such file or directory" when i try to run "af update " – Kimpo May 04 '14 at 11:36