Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ridhwaans opened this issue Nov 1, 2024 · 1 comment

Comments

@ridhwaans
Copy link

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?:
@Pasha28198
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants