wechaty / docker-getting-started

Getting Started Template for Docker Users
https://wechaty.js.org/2018/08/14/docker-wechaty-getting-started/
Apache License 2.0
64 stars 25 forks source link

Docker issure about NPM #7

Closed Vialiceq closed 2 years ago

Vialiceq commented 2 years ago

Q: Could you plz tell me why this happen though I follow the instruction but fail to run in Docker win10 ?

PS D:\A school file\A408\DOCKER\wechaty> docker run -ti --rm --volume="$(pwd)":/bot wechaty/wechaty bot.js

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

WECHATY Environment Variables: 1
WECHATY_DOCKER=1

Starting Docker Container for Wechaty v1.10.4 with Node.js v16.13.0 ...
Working directory: /bot
Please make sure you had installed all the NPM modules which is depended on your bot script.
Executing node bot.js
node:internal/process/esm_loader:94
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/bot/dist/esm/src/mods/mod.js' imported from /bot/bot.js
Did you mean to import wechaty/dist/cjs/src/mods/mod.js?
    at new NodeError (node:internal/errors:371:5)
    at finalizeResolution (node:internal/modules/esm/resolve:405:11)
    at moduleResolve (node:internal/modules/esm/resolve:932:10)
    at defaultResolve (node:internal/modules/esm/resolve:1044:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}
ERROR: Bot exited with code 1
  ____  _   _  ____   ____  _____ ____   ___  ____ _____
 | __ )| | | |/ ___| |  _ \| ____|  _ \ / _ \|  _ \_   _|
 |  _ \| | | | |  _  | |_) |  _| | |_) | | | | |_) || |
 | |_) | |_| | |_| | |  _ <| |___|  __/| |_| |  _ < | |
 |____/ \___/ \____| |_| \_\_____|_|    \___/|_| \_\|_|
huan commented 2 years ago

The log message is clear enough:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/bot/dist/esm/src/mods/mod.js' imported from /bot/bot.js

Please check your bot.js and fix the import path.

Vialiceq commented 2 years ago

thank you

huan commented 2 years ago

You are welcome