Thanks for attaching the proxy bundle.
Not sure exactly what the problem is. but I See a couple problems,.
First, this is the proxy bundle I see
apiproxy/proxies/default.xml
apiproxy/resources/hosted/package.json
apiproxy/resources/hosted/app.yaml
apiproxy/resources/hosted/index.js
apiproxy/resources/node/request.zip
apiproxy/nodejstest.xml
apiproxy/targets/default.xml
apiproxy/manifests/manifest.xml
apiproxy/manifests/hosted-target-manifest.xml
It seems like you have your app logic (index.js) in the resources/hosted directory, and then.. the request.zip thing (a resource I suppose) is in the resources/node directory. That’s not right. You don’t want that. In fact request.zip should not be there, and the resources/node directory should not be there.
Next, this is what I see in package.json :
{
"name": "nodejstest",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"http": "",
"request-promise": ""
}
}
I am not an npm expert, but I think it may be a problem that you don’t have a version numbmer in that package.json file for either of the dependencies. Also , http is a builtin, so you don’t need to reference it in the package.json file. From that I conclude that you are building this dependency file manually. That’s probably the wrong thing to do.
If you try running that nodejs code from a terminal window, does it work? It does not work for me. This is what I see:
$ npm run start
> nodejstest@ start /Users/dchiesa/dev/node/tmp/apiproxy/resources/hosted
> node index.js
###
### The "request" library is not installed automatically anymore.
### But is a dependency of "request-promise".
### Please install it with:
### npm install request --save
###
/Users/dchiesa/dev/node/tmp/apiproxy/resources/hosted/node_modules/request-promise/lib/rp.js:23
throw err;
^
Error: Cannot find module 'request'
Node is telling me that there’s a missing dependency. (I have previously run “npm install”).
So your package.json file is incorrect, and this code won’t run from the terminal. It also won’t run when you try to deploy an aPI Proxy with that code.
To fix those problems, fix the package.json file. First, use a text editor to remove the existing dependencies from that package.json file.
Then, use the npm commands to install dependencies, which automatically updates the package.json file correctly. After these commands:
$ npm install request --save
$ npm install request-promise --save
… I get a package.json file that looks like this :
{
"name": "nodejstest",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"request": "^2.88.0",
"request-promise": "^4.2.5"
}
}
And then running the code from the terminal works.
The next step is to bundle the apiproxy and deploy it. To do that you can use a tool like importAndDeploy.js. This will package up the proxy into a zip, and will correctly exclude the node_modules file. Another option is to use the apigee_tool.
good luck.