Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem starting docker container . SyntaxError: Unexpected token function #352

Closed
dcsan opened this issue Mar 22, 2017 · 1 comment
Closed

Comments

@dcsan
Copy link

dcsan commented Mar 22, 2017

$ docker logs 45dea0b5cad1

 __        __        _           _          
 \ \      / /__  ___| |__   __ _| |_ _   _  
  \ \ /\ / / _ \/ __| '_ \ / _` | __| | | | 
   \ V  V /  __/ (__| | | | (_| | |_| |_| | 
    \_/\_/ \___|\___|_| |_|\__,_|\__|\__, | 
                                     |___/  
____________________________________________________
            https://www.wechaty.io
  ____                            _   _             
 / ___|___  _ __  _ __   ___  ___| |_(_)_ __   __ _ 
| |   / _ \| '_ \| '_ \ / _ \/ __| __| | '_ \ / _` |
| |__| (_) | | | | | | |  __/ (__| |_| | | | | (_| |
 \____\___/|_| |_|_| |_|\___|\___|\__|_|_| |_|\__, |
                                              |___/ 
  ____ _           _   ____        _       
 / ___| |__   __ _| |_| __ )  ___ | |_ ___ 
| |   | '_ \ / _` | __|  _ \ / _ \| __/ __|
| |___| | | | (_| | |_| |_) | (_) | |_\__ \
 \____|_| |_|\__,_|\__|____/ \___/ \__|___/
                                           

Starting Wechaty ... v0.6.47

Working directory: /bot
Install dependencies modules ...
yarn install v0.16.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 67.01s.
Executing node index.js
/bot/index.js:7
(async function init() {
       ^^^^^^^^
SyntaxError: Unexpected token function
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3
  ____  _   _  ____   ____  _____ ____   ___  ____ _____  
 | __ )| | | |/ ___| |  _ \| ____|  _ \ / _ \|  _ \_   _| 
 |  _ \| | | | |  _  | |_) |  _| | |_) | | | | |_) || |   
 | |_) | |_| | |_| | |  _ <| |___|  __/| |_| |  _ < | |   
 |____/ \___/ \____| |_| \_\_____|_|    \___/|_| \_\|_|   
                                                          
Press ENTER to continue ... 

### 1. source code of index.js

const debug = require('debug')("bot:index");
const express = require('express');
const bodyParser = require('body-parser');
const sendMsgToRoom = require('./lib').sendMsgToRoom;
const Kbot = require('./Kbot').Kbot;

(async function init() {
  debug('startup');

  const app = express();
  app.use(bodyParser.json());

  app.post('/api/messages', async (req, res) => {
    const {room, content} = req.body;
    const result = await sendMsgToRoom(room, content);
    res.json(result);
  });

  const port = 8080;
  app.listen(port, () => {
    debug('Wechaty bot listening on port: ', port);
  });

  Kbot.startup();
})();


### 2. directory structor of /bot

total 56
-rw-r--r--   1 root root    99 Mar 22 06:54 Dockerfile
-rw-r--r--   1 root root  2266 Mar 22 06:54 Kbot.js
-rw-r--r--   1 root root   627 Mar 22 06:54 README.md
drwxr-xr-x   2 root root  4096 Mar 22 06:57 bin
drwxr-xr-x   2 root root  4096 Mar 22 06:57 config
-rw-r--r--   1 root root   621 Mar 22 06:54 index.js
-rw-r--r--   1 root root   519 Mar 22 06:54 lib.js
drwxr-xr-x 102 root root  4096 Mar 22 14:05 node_modules
-rw-r--r--   1 root root   580 Mar 22 06:54 package.json
-rw-r--r--   1 root root 19564 Mar 22 14:05 yarn.lock

### 3. package.json

{
  "name": "groups-bot",
  "version": "0.0.1",
  "description": "groups bot",
  "repository": "[email protected]:dcsan/groups-bot.git",
  "license": "ISC",
  "main": "index.ts",
  "scripts": {
    "build": "docker build -t groups-bot .",
    "container": "docker run -ti -d -p 49160:8080 groups-bot",
    "start": "npm run build && npm run container"
  },
  "dependencies": {
    "body-parser": "^1.17.1",
    "debug": "^2.6.3",
    "express": "^4.15.2",
    "finis": "0.0.2",
    "qrcode-terminal": "^0.11.0",
    "request": "^2.81.0",
    "request-promise-native": "^1.0.3"
  }
}

### 4. directory structor inside /bot/node_modules

accepts		     finalhandler	    negotiator
ajv		     finis		    oauth-sign
array-flatten	     forever-agent	    on-finished
asn1		     form-data		    parseurl
assert-plus	     forwarded		    path-to-regexp
asynckit	     fresh		    performance-now
aws-sign2	     getpass		    proxy-addr
aws4		     har-schema		    punycode
bcrypt-pbkdf	     har-validator	    qrcode-terminal
body-parser	     hawk		    qs
boom		     hoek		    range-parser
bytes		     http-errors	    raw-body
caseless	     http-signature	    request
co		     iconv-lite		    request-promise-core
combined-stream      inherits		    request-promise-native
content-disposition  ipaddr.js		    safe-buffer
content-type	     is-typedarray	    send
cookie		     isstream		    serve-static
cookie-signature     jodid25519		    setprototypeof
cryptiles	     jsbn		    sntp
dashdash	     json-schema	    sshpk
debug		     json-stable-stringify  statuses
delayed-stream	     json-stringify-safe    stealthy-require
depd		     jsonify		    stringstream
destroy		     jsprim		    tough-cookie
ecc-jsbn	     lodash		    tunnel-agent
ee-first	     media-typer	    tweetnacl
encodeurl	     merge-descriptors	    type-is
escape-html	     methods		    unpipe
etag		     mime		    utils-merge
express		     mime-db		    uuid
extend		     mime-types		    vary
extsprintf	     ms			    verror

### 5. wechaty doctor


#### Wechaty Doctor

1. Wechaty version: 0.6.47
2. Linux x64 version 4.4.27-moby memory 1511/1997 MB
3. Docker: true
4. Node version: v7.2.1

@dcsan
Copy link
Author

dcsan commented Mar 22, 2017

I had an old wechaty docker image on my system that got picked up.

@dcsan dcsan closed this as completed Mar 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant