mahsankhaan / appsody

Do local development, containerize and migrate to Docker Hub using Appsody
3 stars 1 forks source link

Type error: userApp is not a function #3

Closed karimbzu closed 4 years ago

karimbzu commented 4 years ago

Thanks for sharing this document, I am running "appsody run" command with your guideline, the following error appears, kindly help me to resolve it. image Thanks

mahsankhaan commented 4 years ago

@karimbzu please use "npm install" before running the project and please tell me which command has you executed and got this error ?

karimbzu commented 4 years ago

Here are the commands and their ouput [root@bastion misc]# git clone https://github.com/mahsankhaan/appsody.git Cloning into 'appsody'... remote: Enumerating objects: 127, done. remote: Counting objects: 100% (127/127), done. remote: Compressing objects: 100% (127/127), done. remote: Total 603 (delta 77), reused 0 (delta 0), pack-reused 476 Receiving objects: 100% (603/603), 5.92 MiB | 1.54 MiB/s, done. Resolving deltas: 100% (179/179), done. [root@bastion misc]# cd appsody [root@bastion appsody]# npm install npm WARN myapp@1.0.0 No repository field.

audited 127 packages in 0.786s found 0 vulnerabilities

[root@bastion appsody]# ll total 36 -rw-r--r-- 1 root root 1145 Feb 10 05:08 app.js drwxr-xr-x 2 root root 202 Feb 10 05:08 images drwxr-xr-x 53 root root 4096 Feb 10 05:08 node_modules -rw-r--r-- 1 root root 379 Feb 10 05:08 package.json -rw-r--r-- 1 root root 14512 Feb 10 05:08 package-lock.json drwxr-xr-x 2 root root 39 Feb 10 05:08 public -rw-r--r-- 1 root root 7271 Feb 10 05:08 README.md drwxr-xr-x 2 root root 64 Feb 10 05:08 views [root@bastion appsody]# appsody init incubator/nodejs-express none Checking stack requirements... Docker requirements met Appsody requirements met Running appsody init... Downloading nodejs-express template project from https://github.com/appsody/stacks/releases/download/nodejs-express-v0.4.2/incubator.nodejs-express.v0.4.2.templates.simple.tar.gz Download complete. Do not unzip the template project. Only extracting .appsody-config.yaml file from /home/misc/appsody/nodejs-express.tar.gz Setting up the development environment Your Appsody project name has been set to appsody Pulling docker image docker.io/appsody/nodejs-express:0.4 Running command: docker pull docker.io/appsody/nodejs-express:0.4 0.4: Pulling from appsody/nodejs-express Digest: sha256:55ecd586bcaaeccea841f4b5476e3fdc2234bb95bf1660d6ab38a4ebbae3d7d9 Status: Image is up to date for appsody/nodejs-express:0.4 docker.io/appsody/nodejs-express:0.4 Running command: docker run --rm --entrypoint /bin/bash docker.io/appsody/nodejs-express:0.4 -c find /project -type f -name .appsody-init.sh Successfully initialized Appsody project with the incubator/nodejs-express stack and no template. [root@bastion appsody]# appsody run Running development environment... Pulling docker image docker.io/appsody/nodejs-express:0.4 Running command: docker pull docker.io/appsody/nodejs-express:0.4 0.4: Pulling from appsody/nodejs-express Digest: sha256:55ecd586bcaaeccea841f4b5476e3fdc2234bb95bf1660d6ab38a4ebbae3d7d9 Status: Image is up to date for appsody/nodejs-express:0.4 docker.io/appsody/nodejs-express:0.4 Running command: docker run --rm -p 3000:3000 -p 9229:9229 --name appsody-dev -v /home/misc/appsody/:/project/user-app -v appsody-deps:/project/user-app/node_modules -v appsody-controller-0.3.3:/.appsody -t --entrypoint /.appsody/appsody-controller docker.io/appsody/nodejs-express:0.4 --mode=run [Container] Running APPSODY_PREP command: npm install --prefix user-app && npm audit fix --prefix user-app npm WARN myapp@1.0.0 No repository field. [Container] audited 127 packages in 1.294s [Container] found 0 vulnerabilities [Container] npm WARN myapp@1.0.0 No repository field. [Container] [Container] up to date in 0.307s [Container] fixed 0 of 0 vulnerabilities in 127 scanned packages [Container] [Container] [Container] ╭────────────────────────────────────────────────────────────────╮ [Container] │ │ [Container] │ New patch version of npm available! 6.13.4 -> 6.13.7 │ [Container] │ Changelog: https://github.com/npm/cli/releases/tag/v6.13.7 │ [Container] │ Run npm install -g npm to update! │ [Container] │ │ [Container] ╰────────────────────────────────────────────────────────────────╯ [Container] [Container] Running command: npm start [Container] [Container] > nodejs-express@0.4.2 start /project [Container] > node server.js [Container] [Container] [Mon Feb 10 10:09:34 2020] com.ibm.diagnostics.healthcenter.loader INFO: Node Application Metrics 5.1.1.202002071510 (Agent Core 4.0.5) [Container] [Mon Feb 10 10:09:34 2020] com.ibm.diagnostics.healthcenter.mqtt INFO: Connecting to broker localhost:1883 [Container] /project/server.js:35 [Container] app.use('/', userApp({ [Container] ^ [Container] [Container] TypeError: userApp is not a function [Container] at Object. (/project/server.js:35:14) [Container] at Module._compile (internal/modules/cjs/loader.js:955:30) [Container] at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10) [Container] at Module.load (internal/modules/cjs/loader.js:811:32) [Container] at Function.Module._load (internal/modules/cjs/loader.js:723:14) [Container] at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) [Container] at internal/main/run_main_module.js:17:11 [Container] npm ERR! code ELIFECYCLE [Container] npm ERR! errno 1 [Container] npm ERR! nodejs-express@0.4.2 start: node server.js [Container] npm ERR! Exit status 1 [Container] npm ERR! [Container] npm ERR! Failed at the nodejs-express@0.4.2 start script. [Container] npm ERR! This is probably not a problem with npm. There is likely additional logging output above. [Container] [Container] npm ERR! A complete log of this run can be found in: [Container] npm ERR! /root/.npm/_logs/2020-02-10T10_09_35_084Z-debug.log [Container] Wait received error on APPSODY_RUN/DEBUG/TEST exit status 1

mahsankhaan commented 4 years ago

@karimbzu have you followed the prerequisites ?

karimbzu commented 4 years ago

Ahsan i have installed all the prerequisites, i am running other projects with appsody such as : https://github.com/KrunalLathiya/node-js-express-tutorial.git https://github.com/microsoft/project-nodejs-express-webapp.git But for this project, I am getting this error.

karimbzu commented 4 years ago

image Same error on VS code

mahsankhaan commented 4 years ago

@karimbzu have you successfully run this project ? or still getting any error ?

ragdeshp commented 4 years ago

We see the same error on VSCode and appsody run fails