ts-node icon indicating copy to clipboard operation
ts-node copied to clipboard

TypeError: value.replace is not a function on yarn 4.5.1, Node.js v20.13.1

Open ridhwaans opened this issue 1 year ago • 2 comments

Search Terms

Expected Behavior

I expect ts-node to run src/index.ts without errors

Actual Behavior

yarn run dotenv -e ../web/.env.local -- ts-node src/index.ts
/home/ridhwaans/Source/test/.yarn/__virtual__/ts-node-virtual-c211acd0da/3/.yarn/berry/cache/ts-node-npm-10.9.2-3f3890b9ac-10c0.zip/node_modules/ts-node/dist/util.js:62
    return value.replace(backslashRegExp, directorySeparator);
                 ^

TypeError: value.replace is not a function
    at normalizeSlashes (/home/ridhwaans/Source/test/.yarn/__virtual__/ts-node-virtual-c211acd0da/3/.yarn/berry/cache/ts-node-npm-10.9.2-3f3890b9ac-10c0.zip/node_modules/ts-node/dist/util.js:62:18)
    at Object.getExtendsConfigPath (/home/ridhwaans/Source/test/.yarn/__virtual__/ts-node-virtual-c211acd0da/3/.yarn/berry/cache/ts-node-npm-10.9.2-3f3890b9ac-10c0.zip/node_modules/ts-node/dist/ts-internals.js:24:54) 
    at readConfig (/home/ridhwaans/Source/test/.yarn/__virtual__/ts-node-virtual-c211acd0da/3/.yarn/berry/cache/ts-node-npm-10.9.2-3f3890b9ac-10c0.zip/node_modules/ts-node/dist/configuration.js:127:64)
    at findAndReadConfig (/home/ridhwaans/Source/test/.yarn/__virtual__/ts-node-virtual-c211acd0da/3/.yarn/berry/cache/ts-node-npm-10.9.2-3f3890b9ac-10c0.zip/node_modules/ts-node/dist/configuration.js:50:84)
    at phase3 (/home/ridhwaans/Source/test/.yarn/__virtual__/ts-node-virtual-c211acd0da/3/.yarn/berry/cache/ts-node-npm-10.9.2-3f3890b9ac-10c0.zip/node_modules/ts-node/dist/bin.js:254:67)
    at bootstrap (/home/ridhwaans/Source/test/.yarn/__virtual__/ts-node-virtual-c211acd0da/3/.yarn/berry/cache/ts-node-npm-10.9.2-3f3890b9ac-10c0.zip/node_modules/ts-node/dist/bin.js:47:30)
    at main (/home/ridhwaans/Source/test/.yarn/__virtual__/ts-node-virtual-c211acd0da/3/.yarn/berry/cache/ts-node-npm-10.9.2-3f3890b9ac-10c0.zip/node_modules/ts-node/dist/bin.js:33:12)
    at Object.<anonymous> (/home/ridhwaans/Source/test/.yarn/__virtual__/ts-node-virtual-c211acd0da/3/.yarn/berry/cache/ts-node-npm-10.9.2-3f3890b9ac-10c0.zip/node_modules/ts-node/dist/bin.js:579:5)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)

Node.js v20.13.1

Steps to reproduce the problem

  1. Install yarn 4.5.1 (berry)
  2. yarn add ts-node --dev
  3. Install dotenv
  4. copy the src/index.ts, tsup and ts-node configs
  5. Run `yarn run dotenv -e ../web/.env.local -- ts-node src/index.ts
//tsup.config.ts
import { defineConfig } from 'tsup';

export default defineConfig((opts) => ({
  entry: ['./src/index.ts'],
  format: ['cjs'], // CommonJS format
  splitting: false, // Avoid splitting
  sourcemap: true,
  minify: !opts.watch,
  clean: !opts.watch,
  dts: true,
  outDir: 'dist',
  esbuildOptions: (options) => {
    options.external = ['path', 'fs', 'os']; // Mark Node.js built-in modules as external
    options.platform = 'node'; // Ensure the target platform is Node.js
  },
}));

Minimal reproduction

Specifications

  • ts-node version: ^10.9.2
  • node version: v20.13.1
  • TypeScript version: "typescript": "^5.4.5", 5.0.0
  • tsconfig.json, if you're using one:
//tsconfig.json
{
  "extends": ["@project/tsconfig/base.json"],
  "compilerOptions": {
    "tsBuildInfoFile": ".tsbuildinfo",
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["**/*.ts", "**/*.js"]
}

  • package.json:
  "devDependencies": {
 "@project/tsconfig": "workspace:^",
    "@types/bun": "^1.1.3",
    "dotenv-cli": "^7.4.2",
    "ts-node": "^10.9.2",
    "tsup": "^8.0.2"
  }

  • Operating system and version:
  • If Windows, are you using WSL or WSL2?:

ridhwaans avatar Nov 01 '24 18:11 ridhwaans

Try to update tsconfig.json with these changes from extends: ['...'] to extends: '...'

phnydyn avatar Nov 05 '24 00:11 phnydyn

Try to update tsconfig.json with these changes from extends: ['...'] to extends: '...'

just curious - why does this matter?

andrewmueller1 avatar Dec 02 '25 13:12 andrewmueller1