-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Labels
status: duplicateIs a duplicate of another issueIs a duplicate of another issue
Description
Bug report
Required System information
- Node.js version: 16.16.0
- NPM version: 8.11.0
- Strapi version: 4.3.6
- Database: Postgres
- Operating system: Windows 10
Describe the bug
When starting Strapi with a Typescript-enabled project, in the getConfigPath function, dirAbsolutePath = path.resolve(dir) return backward slash but typescript's ts.findConfigFile return forward slash. So when checking directory using configFilePath.startsWith, instead of true, it return false even if tsconfig.json is exists in both root and admin folder.
Steps to reproduce the behavior
- Create Strapi project with Typescript support and create
tsconfig.jsonaccording to Strapi documentation yarnyarn start- See error
Expected behavior
getConfigPath should return true if tsconfig.json is exists.
Screenshots
PS <project folder>\app> yarn strapi start
yarn run v1.22.19
warning ..\..\..\..\package.json: No license field
$ strapi start
getConfigPath <project folder>\app tsconfig.json <project folder>/app/tsconfig.json
<project folder>\app isTSProject false
getConfigPath <project folder>\app tsconfig.json <project folder>/app/tsconfig.json
getConfigPath <project folder>\app tsconfig.json <project folder>/app/tsconfig.json
getConfigPath <project folder>\app\src\admin tsconfig.json <project folder>/app/src/admin/tsconfig.json
[2022-09-03 22:31:53.588] debug: ⛔️ Server wasn't able to start properly.
[2022-09-03 22:31:53.591] error: Unknown dialect undefined
Error: Unknown dialect undefined
at getDialectClass (<project folder>\app\node_modules\@strapi\database\lib\dialects\index.js:12:13)
at getDialect (<project folder>\app\node_modules\@strapi\database\lib\dialects\index.js:19:23)
at new Database (<project folder>\app\node_modules\@strapi\database\lib\index.js:27:20)
at Function.Database.init (<project folder>\app\node_modules\@strapi\database\lib\index.js:77:35)
at Strapi.bootstrap (<project folder>\app\node_modules\@strapi\strapi\lib\Strapi.js:392:30)
at Strapi.load (<project folder>\app\node_modules\@strapi\strapi\lib\Strapi.js:457:16)
at async Strapi.start (<project folder>\app\node_modules\@strapi\strapi\lib\Strapi.js:198:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Code snippets
Modified from get-config-path.js
module.exports = (dir, { filename = DEFAULT_TS_CONFIG_FILENAME, ancestorsLookup = false } = {}) => {
const dirAbsolutePath = path.resolve(dir);
const configFilePath = ts.findConfigFile(dirAbsolutePath, ts.sys.fileExists, filename);
console.log('getConfigPath', dirAbsolutePath, filename, configFilePath);
...
Potential solution
Instead of String.startsWith, use path.normalize first.
lessborders
Metadata
Metadata
Assignees
Labels
status: duplicateIs a duplicate of another issueIs a duplicate of another issue
