TypeError: path.charCodeAt is not a function #9

Closed
opened 2022-06-04 15:22:17 +02:00 by arnoson · 8 comments
arnoson commented 2022-06-04 15:22:17 +02:00 (Migrated from github.com)

When trying to build the language example I get the following error:

[!] (plugin Typescript) TypeError: path.charCodeAt is not a function
src/index.ts
TypeError: path.charCodeAt is not a function
    at getEncodedRootLength (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:7660:24)
    at Object.isRootedDiskPath (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:7567:16)
    at Object.isExternalModuleNameRelative (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:12360:52)
    at tryLoadModuleUsingOptionalResolutionSettings (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43172:17)
    at tryResolve (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43375:28)
    at /home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43371:69
    at Object.forEach (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:377:30)
    at nodeModuleNameResolverWorker (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43371:25)
    at nodeModuleNameResolver (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43346:16)
    at Object.resolveModuleName (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43073:30)
When trying to build the language example I get the following error: ``` [!] (plugin Typescript) TypeError: path.charCodeAt is not a function src/index.ts TypeError: path.charCodeAt is not a function at getEncodedRootLength (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:7660:24) at Object.isRootedDiskPath (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:7567:16) at Object.isExternalModuleNameRelative (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:12360:52) at tryLoadModuleUsingOptionalResolutionSettings (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43172:17) at tryResolve (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43375:28) at /home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43371:69 at Object.forEach (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:377:30) at nodeModuleNameResolverWorker (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43371:25) at nodeModuleNameResolver (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43346:16) at Object.resolveModuleName (/home/arno/development/lang-example/node_modules/typescript/lib/typescript.js:43073:30) ```
marijnh commented 2022-06-04 19:46:27 +02:00 (Migrated from github.com)

Does this happen after you run npm install in a fresh clone of this repository?

Does this happen after you run `npm install` in a fresh clone of this repository?
arnoson commented 2022-06-04 20:08:45 +02:00 (Migrated from github.com)

Yes, happens right after npm install on a fresh clone or after runing rollup -c manually.
My node version is v16.15.0 and I'm running it on WSL2

Yes, happens right after `npm install` on a fresh clone or after runing `rollup -c` manually. My node version is `v16.15.0` and I'm running it on WSL2
marijnh commented 2022-06-04 20:32:40 +02:00 (Migrated from github.com)

Odd. On my system (Linux, node 16, npm 8) I can install and build without issue.

Odd. On my system (Linux, node 16, npm 8) I can install and build without issue.
arnoson commented 2022-06-04 21:06:21 +02:00 (Migrated from github.com)

Okay this is really odd indeed, I switched to rollup-plugin-esbuild and everything works again

Okay this is really odd indeed, I switched to `rollup-plugin-esbuild` and everything works again
isaiahdahl commented 2022-06-24 01:12:44 +02:00 (Migrated from github.com)

I'm also getting this issue. Mac, node 18, yarn 1.22.17

Edit: figured it out with rollup-plugin-esbuild as well

I'm also getting this issue. Mac, node 18, yarn 1.22.17 Edit: figured it out with `rollup-plugin-esbuild` as well
corwin-of-amber commented 2022-07-06 19:37:08 +02:00 (Migrated from github.com)

I think the dependency rollup-plugin-ts has to be updated. After running npm i rollup-plugin-ts@latest (currently 3.0.2) I am no longer seeing this error.

I think the dependency `rollup-plugin-ts` has to be updated. After running `npm i rollup-plugin-ts@latest` (currently 3.0.2) I am no longer seeing this error.
Enchiridion commented 2022-07-21 23:09:24 +02:00 (Migrated from github.com)

@corwin-of-amber Thanks for that tip! I was getting the exact same issue (Win 10, node 16, npm 8). I'm not familiar with rollup (webpack user here) so that saved me a ton of time.

@corwin-of-amber Thanks for that tip! I was getting the exact same issue (Win 10, node 16, npm 8). I'm not familiar with rollup (webpack user here) so that saved me a ton of time.
StoneCypher commented 2022-09-17 21:04:33 +02:00 (Migrated from github.com)

Windows 10, node 18.4.0, npm 7.2.0, also saved by @corwin-of-amber 's observation

Submitting a patch to fix

Windows 10, node 18.4.0, npm 7.2.0, also saved by @corwin-of-amber 's observation Submitting a patch to fix
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/lang-example#9
No description provided.