wechaty / getting-started

A Starter Project Template for Wechaty works out-of-the-box
https://gitpod.io/#https://github.com/wechaty/wechaty-getting-started
Apache License 2.0
774 stars 342 forks source link

启动报:TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" #213

Closed 18237966658 closed 2 years ago

18237966658 commented 2 years ago

启动时报:

wechaty-getting-started@0.13.13 start cross-env NODE_OPTIONS='--no-warnings --loader=ts-node/esm' node examples/ding-dong-bot.ts

internal/process/esm_loader.js:74 internalBinding('errors').triggerUncaughtException( ^

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for D:\wechaty-getting-started-main\examples\ding-dong-bot.ts at Loader.defaultGetFormat [as _getFormat] (internal/modules/esm/get_format.js:71:15) at Loader.getFormat (internal/modules/esm/loader.js:105:42) at Loader.getModuleJob (internal/modules/esm/loader.js:243:31) at async Loader.import (internal/modules/esm/loader.js:177:17) at async Object.loadESM (internal/process/esm_loader.js:68:5) { code: 'ERR_UNKNOWN_FILE_EXTENSION' }

huan commented 2 years ago

Wechaty requires Node.js version 16+, please upgrade your Node.js

18237966658 commented 2 years ago
D:\DaiMa\wechaty\wechaty-getting-started-main>npm start

> wechaty-getting-started@0.13.13 start
> cross-env NODE_OPTIONS='--no-warnings --loader=ts-node/esm' node examples/ding-dong-bot.ts

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for D:\DaiMa\wechaty\wechaty-getting-started-main\examples\ding-dong-bot.ts
    at new NodeError (node:internal/errors:371:5)
    at Loader.defaultGetFormat [as _getFormat] (node:internal/modules/esm/get_format:71:15)
    at Loader.getFormat (node:internal/modules/esm/loader:105:42)
    at Loader.getModuleJob (node:internal/modules/esm/loader:243:31)
    at async Loader.import (node:internal/modules/esm/loader:177:17)
    at async Object.loadESM (node:internal/process/esm_loader:68:5)
    at async handleMainPromise (node:internal/modules/run_main:63:12) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

D:\DaiMa\wechaty\wechaty-getting-started-main>node -v
v16.10.0

Node.js version 16.10.0

18237966658 commented 2 years ago
npm ERR! code 1
npm ERR! path D:\DaiMa\wechaty\wechaty-getting-started-main\node_modules\sharp
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! �ڴ˽��������һ������һ����Ŀ����Ҫ���ò������ɣ������ӡ�-m�����ء�
npm ERR!   nothing.c
npm ERR!   win_delay_load_hook.cc
npm ERR!   nothing.vcxproj -> D:\DaiMa\wechaty\wechaty-getting-started-main\node_modules\sharp\build\Release\\nothing.lib
npm ERR!   VError.cpp
npm ERR! D:\DaiMa\wechaty\wechaty-getting-started-main\node_modules\sharp\src\libvips\cplusplus\VError.cpp(33,10): fatal error C1083: �޷�������ļ�: ��vips/intl.h��: No
such file or directory [D:\DaiMa\wechaty\wechaty-getting-started-main\node_modules\sharp\build\libvips-cpp.vcxproj]
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@16.10.0 | win32 | ia32
npm ERR! gyp info find Python using Python version 3.9.7 found at "C:\Python39\python.exe"
npm ERR! gyp info find VS using VS2019 (16.11.31702.278) found at:
npm ERR! gyp info find VS "D:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! (node:4740) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! gyp info spawn C:\Python39\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'F:\\node\\node_global\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'D:\\DaiMa\\wechaty\\wechaty-getting-started-main\\node_modules\\sharp\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'F:\\node\\node_global\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\d\\AppData\\Local\\node-gyp\\Cache\\16.10.0\\include\\node\\common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\d\\AppData\\Local\\node-gyp\\Cache\\16.10.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=F:\\node\\node_global\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\d\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.10.0\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=D:\\DaiMa\\wechaty\\wechaty-getting-started-main\\node_modules\\sharp',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'D:\\DaiMa\\wechaty\\wechaty-getting-started-main\\node_modules\\sharp\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=Win32'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (F:\node\node_global\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19041
npm ERR! gyp ERR! command "D:\\node\\node.exe" "F:\\node\\node_global\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd D:\DaiMa\wechaty\wechaty-getting-started-main\node_modules\sharp
npm ERR! gyp ERR! node -v v16.10.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     F:\node\node_cache\_logs\2021-09-26T04_27_56_086Z-debug.log

上述为:npm install 时报错 系统环境为: Node.js version 16.10.0 ia32 Python version 3.9.7 Visual Studio 2019

请问是什么原因导致的

SCHLLLLLL commented 2 years ago

同样遇到这个问题 nvs use 16

huan commented 2 years ago

Thanks for the reporting @SCHLLLLLL @18237966658

It seems this is related to the ' vs " under windows system, should be fixed by https://github.com/wechaty/wechaty-getting-started/commit/170915adc6ec9193cc6c8963decaa3e477e870fd

Please check out the latest main version with v0.13.14+ and let me know if this issue has been resolved or not.

huan commented 2 years ago

Confirmed with @SCHLLLLLL that this issue has been fixed.