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

Local Build Plugin fails with TypeScript: TypeError: value.replace is not a function #5818

Open
Joroze opened this issue Aug 27, 2024 · 3 comments
Labels
type: bug code to address defects in shipped code

Comments

@Joroze
Copy link

Joroze commented Aug 27, 2024

Describe the bug

When running a basic build plugin written in TypeScript (via Netlify CLI or through Netlify's build pipeline itself upon deployment), it fails with the following error:

TypeError: value.replace is not a function

I believe the underlying culprit might be the ts-node dependency in this repository. I traced it back to the following issue opened here:

It seems ts-node is no longer maintained.

Steps to reproduce

With a simple build plugin as mentioned in the Netlify docs, but use TypeScript by renaming your file from .js to .ts like so: index.ts

index.ts

export const onPreBuild = async () => {
  console.log('Hello');
};

netlify.toml

[[plugins]]
  package = "./packages/netlify-plugins/my-plugin"

npx netlify build

CLI command and flags

npx netlify build

Configuration

[[plugins]]
  package = "./packages/netlify-plugins/my-plugin"

CLI output

1:18:07 PM: Plugin "./packages/netlify-plugins/my-plugin" internal error
1:18:07 PM: ──────────────────────────────────────────────────────────────────────────────────
1:18:07 PM: ​
1:18:07 PM: Error message
1:18:07 PM: TypeError: value.replace is not a function
1:18:07 PM: ​
1:18:07 PM: Plugin details
1:18:07 PM: Package: ./packages/netlify-plugins/my-plugin
1:18:07 PM: Version: 0.0.0
1:18:07 PM: ​
1:18:07 PM: Error location
1:18:07 PM: While loading "./packages/netlify-plugins/my-plugin" from netlify.toml
1:18:07 PM: at normalizeSlashes (/opt/buildhome/node-deps/node_modules/ts-node/dist/util.js:62:18)
1:18:07 PM: at Object.getExtendsConfigPath (/opt/buildhome/node-deps/node_modules/ts-node/dist/ts-internals.js:24:54)
1:18:07 PM: at readConfig (/opt/buildhome/node-deps/node_modules/ts-node/dist/configuration.js:127:64)
1:18:07 PM: at findAndReadConfig (/opt/buildhome/node-deps/node_modules/ts-node/dist/configuration.js:50:84)
1:18:07 PM: at create (/opt/buildhome/node-deps/node_modules/ts-node/dist/index.js:146:69)
1:18:07 PM: at register (/opt/buildhome/node-deps/node_modules/ts-node/dist/index.js:127:19)
1:18:07 PM: at registerTypeScript (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/plugins/child/typescript.js:12:12)
1:18:07 PM: at Object.load (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/plugins/child/load.js:11:27)
1:18:07 PM: at handleEvent (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/plugins/child/main.js:28:65)
1:18:07 PM: at file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/plugins/child/main.js:23:63

Environment

System:
OS: macOS 15.1
CPU: (8) arm64 Apple M2
Memory: 72.89 MB / 16.00 GB
Shell: 3.7.1 - /opt/homebrew/bin/fish
Binaries:
Node: 22.6.0 - ~/.local/share/nvm/v22.6.0/bin/node
npm: 10.8.2 - ~/.local/share/nvm/v22.6.0/bin/npm
npmGlobalPackages:
netlify-cli: 17.34.3

@Joroze Joroze added the type: bug code to address defects in shipped code label Aug 27, 2024
@Joroze Joroze changed the title Local Build Plugin using TypeScript: TypeError: value.replace is not a function Local Build Plugin fails with TypeScript: TypeError: value.replace is not a function Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

8 participants
@Joroze and others