Recently did encounter an issue where npm install management API was not working on OPDK 15.07.03
Below was the error that we were getting:
[root@ip-10-167-1-91 apps]# curl --header "Content-Type: application/x-www-form-urlencoded" -d "command=install" -v -u $pass http://10.167.1.91:8080/v1/organizations/npmtest/apis/testapi/revisions/1/npm * About to connect() to 10.167.1.91 port 8080 (#0) * Trying 10.167.1.91... connected * Connected to 10.167.1.91 (10.167.1.91) port 8080 (#0) * Server auth using Basic with user 'jhans@apigee.com' > POST /v1/organizations/npmtest/apis/testapi/revisions/1/npm HTTP/1.1 > Authorization: Basic *********************** > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: 10.167.1.91:8080 > Accept: */* > Content-Type: application/x-www-form-urlencoded > Content-Length: 15 > < HTTP/1.1 500 Server Error < Content-Type: text/plain < Date: Thu, 22 Sep 2016 05:13:17 GMT < Content-Length: 1137 < npm ERR! { [Error: connect ECONNREFUSED] npm ERR! message: 'connect ECONNREFUSED', npm ERR! code: 'ECONNREFUSED', npm ERR! errno: 'ECONNREFUSED', npm ERR! syscall: 'connect', npm ERR! parent: 'awssns' } npm ERR! npm ERR! If you are behind a proxy, please make sure that the npm ERR! 'proxy' config is set properly. See: 'npm help config' npm ERR! System Trireme Trireme npm ERR! command "./node" "/apps/apigee4/share/apigee/lib/node_modules/npm/cli.js" "--loglevel" "error" "--registry" "https://apigee.registry.nodejitsu.com" "--cache" "/apps/apigee4/var/log/apigee/management-server/work/npm-cache" "--ignore-scripts" "true" "--bin-links" "false" "--json" "install" npm ERR! cwd /apps/apigee4/var/log/apigee/management-server/work/npm/npm4151602594990181914.tmp npm ERR! node -v v0.10.32 npm ERR! npm -v 1.4.3 npm ERR! syscall connect npm ERR! code ECONNREFUSED npm ERR! errno ECONNREFUSED npm ERR! stack connect ECONNREFUSED npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /apps/apigee4/var/log/apigee/management-server/work/npm/npm4151602594990181914.tmp/npm-debug.log npm ERR! not ok code 0 * Connection #0 to host 10.167.1.91 left intact * Closing connection #0 [root@ip-10-167-1-91 apps]#
The same npm API works fine in cloud but fails in OPDK.
Below are the changes that we need to make it work:
vim ./conf/apigee/management-server/nodejs.properties
Change below:
#npm.registry.uri=https://apigee.registry.nodejitsu.com
npm.registry.uri=https://registry.npmjs.org
Once you change this run the command again:
[root@ip-10-167-1-91 apigee4]# curl --header "Content-Type: application/x-www-form-urlencoded" -d "command=install" -v -u $pass http://10.167.1.91:8080/v1/organizations/npmtest/apis/testapi/revisions/1/npm * About to connect() to 10.167.1.91 port 8080 (#0) * Trying 10.167.1.91... connected * Connected to 10.167.1.91 (10.167.1.91) port 8080 (#0) * Server auth using Basic with user 'jhans@apigee.com' > POST /v1/organizations/npmtest/apis/testapi/revisions/1/npm HTTP/1.1 > Authorization: Basic **************** > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: 10.167.1.91:8080 # callback function within this timeout. In other words, this timeout prevents > Accept: */* > Content-Type: application/x-www-form-urlencoded > Content-Length: 15 > < HTTP/1.1 500 Server Error < Content-Type: text/plain < Date: Mon, 26 Sep 2016 04:26:45 GMT < Content-Length: 51 < npm ERR! cb() never called! npm ERR! not ok code 0 * Connection #0 to host 10.167.1.91 left intact * Closing connection #0 [root@ip-10-167-1-91 apigee4]#
This would happen due to cached entries in node js.
To fix this change below in the same nodejs.properties
max.class.cache.entries=0
Each time you change nodejs.properties file, restart the management server.
Once the restart is done it install npm dependencies when we run the API call.
[root@ip-10-167-1-91 apigee4]# curl --header "Content-Type: application/x-www-form-urlencoded" -d "command=install" -v -u $pass http://10.167.1.91:8080/v1/organizations/npmtest/apis/testapi/revisions/1/npm * About to connect() to 10.167.1.91 port 8080 (#0) * Trying 10.167.1.91... connected * Connected to 10.167.1.91 (10.167.1.91) port 8080 (#0) * Server auth using Basic with user 'jhans@apigee.com' > POST /v1/organizations/npmtest/apis/testapi/revisions/1/npm HTTP/1.1 > Authorization: Basic ************** > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: 10.167.1.91:8080 > Accept: */* > Content-Type: application/x-www-form-urlencoded > Content-Length: 15 > < HTTP/1.1 200 OK < Content-Type: application/json < Date: Mon, 26 Sep 2016 04:40:15 GMT < Content-Length: 7860 < [ { "name": "express", "version": "4.14.0", "from": "express@^4.14.0", "dependencies": { "escape-html": { "version": "1.0.3", "from": "escape-html@~1.0.3", "dependencies": {} }, "array-flatten": { "version": "1.1.1", "from": "array-flatten@1.1.1", "dependencies": {} }, "cookie-signature": { "version": "1.0.6", "from": "cookie-signature@1.0.6", "dependencies": {} }, "path-to-regexp": { "version": "0.1.7", "from": "path-to-regexp@0.1.7", "dependencies": {} }, "utils-merge": { "version": "1.0.0", "from": "utils-merge@1.0.0", "dependencies": {} }, "methods": { "version": "1.1.2", "from": "methods@~1.1.2", "dependencies": {} }, "fresh": { "version": "0.3.0", "from": "fresh@0.3.0", "dependencies": {} },
Change the cache entries back to 2000 in nodejs.properties once the npm install works.
Regards,
Jagjyot
is this still relevant? Does it apply to SaaS?
since nodejitsu.com was acquired by Go Daddy - is there an EOL?
And finally - https://apigee.registry.nodejitsu.com - is no longer resolving.
yes Its still valid. I have mentioned the change in URL above:
This is the extract:
Change below: #npm.registry.uri=https://apigee.registry.nodejitsu.com npm.registry.uri=https://registry.npmjs.org