Giter Site home page Giter Site logo

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["X-React-Native-Project-Root"] at ServerResponse.setHeader (node:_http_outgoing:651:3) about cli HOT 16 CLOSED

bouakram avatar bouakram commented on June 14, 2024 2
TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["X-React-Native-Project-Root"] at ServerResponse.setHeader (node:_http_outgoing:651:3)

from cli.

Comments (16)

RafikGadzhiyev avatar RafikGadzhiyev commented on June 14, 2024 43

I had the same issue. And I was researching a lot and I found this^

  1. Go to node_modules/@react-native-community/cli-server-api/build/statusPageMiddleware.js
  2. On line 19 wrap process.cwd() to new URL() like this:
    new URL(process.cwd())
  3. Before reload clean cache in npm using npm cache clean --force
  4. Run using npm run start / npm run android

I hope this will help you too 😇

from cli.

Andrey123815 avatar Andrey123815 commented on June 14, 2024 11

THE PROBLEM IS ONLY IN PATH TO YOUR PROJECT

You can use only latine chars, may also use "-" in naming

If your path to project naming is correct you dont need any ways written higher

But if you need path with not correct chars you may
CHANGE IN FILE node_modules/@react-native-community/cli-server-api/build/statusPageMiddleware.js STRING
res.setHeader('X-React-Native-Project-Root', process.cwd());
TO
res.setHeader('X-React-Native-Project-Root', new URL(process.cwd(), 'file://'));

and always will work (don't forget to clear cache!)

newc URL allow us to make ref to local root file, for example:
for path "/home/user/Рабочий стол" link pathname will be like "'/home/user/%D0%A0%D0%B0%D0%B1%D0%BE%D1%87%D0%B8%D0%B9%20%D1%81%D1%82%D0%BE%D0%BB"

from cli.

bouakram avatar bouakram commented on June 14, 2024 7

I had the same issue. And I was researching a lot and I found this^

  1. Go to node_modules/@react-native-community/cli-server-api/build/statusPageMiddleware.js
  2. On line 19 wrap process.cwd() to new URL() like this:
    new URL(process.cwd())
  3. Before reload clean cache in npm using npm cache clean --force
  4. Run using npm run start / npm run android

I hope this will help you too 😇

thank you saved my dev day 😊

from cli.

arnaudambro avatar arnaudambro commented on June 14, 2024 7

I had the same issue. And I was researching a lot and I found this^

  1. Go to node_modules/@react-native-community/cli-server-api/build/statusPageMiddleware.js
  2. On line 19 wrap process.cwd() to new URL() like this:
    new URL(process.cwd())
  3. Before reload clean cache in npm using npm cache clean --force
  4. Run using npm run start / npm run android

I hope this will help you too 😇

I got

TypeError: Invalid URL
    at new URL (node:internal/url:775:36)
    at statusPageMiddleware (/node_modules/@react-native-community/cli-server-api/build/statusPageMiddleware.js:20:48)
``

from cli.

whitebrand avatar whitebrand commented on June 14, 2024 7

Same here, did you solve it @arnaudambro ?

UPDATE: If anyone else has the same error, please, check your project folder path and confirm there aren´t any special characteres on it. In the example of this issue the path has Arabic characters C:\Users\kikou\OneDrive\المستندات\ReactNative projects\, same for accents "áéíóú", "àèìòù" or any other non english "çñ..." character. Check this for the full path and then try to build the app again.

from cli.

begench-g avatar begench-g commented on June 14, 2024 2

THE PROBLEM IS ONLY IN PATH TO YOUR PROJECT

You can use only latine chars, may also use "-" in naming

If your path to project naming is correct you dont need any ways written higher

But if you need path with not correct chars you may CHANGE IN FILE node_modules/@react-native-community/cli-server-api/build/statusPageMiddleware.js STRING res.setHeader('X-React-Native-Project-Root', process.cwd()); TO res.setHeader('X-React-Native-Project-Root', new URL(process.cwd(), 'file://'));

and always will work (don't forget to clear cache!)

newc URL allow us to make ref to local root file, for example: for path "/home/user/Рабочий стол" link pathname will be like "'/home/user/%D0%A0%D0%B0%D0%B1%D0%BE%D1%87%D0%B8%D0%B9%20%D1%81%D1%82%D0%BE%D0%BB"

Thank you, this worked for me.

from cli.

GustavoHNRamos avatar GustavoHNRamos commented on June 14, 2024 2

Same here, did you solve it @arnaudambro ?

UPDATE: If anyone else has the same error, please, check your project folder path and confirm there aren´t any special characteres on it. In the example of this issue the path has Arabic characters C:\Users\kikou\OneDrive\المستندات\ReactNative projects\, same for accents "áéíóú", "àèìòù" or any other non english "çñ..." character. Check this for the full path and then try to build the app again.

Thank you, my path had a non english character

from cli.

bouakram avatar bouakram commented on June 14, 2024 1

the solution provided by @RafikGadzhiyev is correct thanks to him.

from cli.

ThienLE0811 avatar ThienLE0811 commented on June 14, 2024 1

I had the same issue. And I was researching a lot and I found this^

  1. Go to node_modules/@react-native-community/cli-server-api/build/statusPageMiddleware.js
  2. On line 19 wrap process.cwd() to new URL() like this:
    new URL(process.cwd())
  3. Before reload clean cache in npm using npm cache clean --force
  4. Run using npm run start / npm run android

I hope this will help you too 😇

Thank you, my problem has been solved

from cli.

pauloscardoso avatar pauloscardoso commented on June 14, 2024 1

O mesmo aqui, você resolveu@arnaudambro?

ATUALIZAÇÃO: Se alguém tiver o mesmo erro, por favor, verifique o caminho da pasta do seu projeto e confirme se não há caracteres especiais nela. No exemplo desta edição o caminho possui caracteres árabes C:\Users\kikou\OneDrive\المستندات\ReactNative projects\, o mesmo para acentos "áéíóú", "àèìòù" ou qualquer outro caractere "çñ..." não inglês. Verifique o caminho completo e tente criar o aplicativo novamente.

Sorted out. My path had space between two texts. Space removed and the problem went away.

from cli.

Andrey123815 avatar Andrey123815 commented on June 14, 2024 1

My path looks fine, but I still get an error

TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:400:5)
at URL.onParseError (node:internal/url:565:9)
at new URL (node:internal/url:645:5)
at statusPageMiddleware (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/@react-native-community/cli-server-api/build/statusPageMiddleware.js:19:48)
at call (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:239:7)
at next (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:183:5)
at next (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)
at next (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)
at next (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)
at next (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)

You can try to move project to another path or try the second way described in my answer higher

from cli.

itlingxiu avatar itlingxiu commented on June 14, 2024 1

@bouakram 这个方法也可以解决那个问题2. new URL()

from cli.

hw514352 avatar hw514352 commented on June 14, 2024

deleting the 19 line X-React-Native-Project-Root

from cli.

wencai123 avatar wencai123 commented on June 14, 2024

My path looks fine, but I still get an error

TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:400:5)
at URL.onParseError (node:internal/url:565:9)
at new URL (node:internal/url:645:5)
at statusPageMiddleware (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/@react-native-community/cli-server-api/build/statusPageMiddleware.js:19:48)
at call (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:239:7)
at next (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:183:5)
at next (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)
at next (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)
at next (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)
at next (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)

from cli.

wencai123 avatar wencai123 commented on June 14, 2024

我的路径看起来不错,但仍然出现错误
TypeError [ERR_INVALID_URL]:
新的 NodeError (node:internal/errors:400:5) 处的URL 无效。新的 URL
(node:internal/url:645:5) 处的 URL.onParseError (
node:internal/url:565:9) 处的 URL 无效
在 statusPageMiddleware (/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/@react-native-community/cli-server-api/build/statusPageMiddleware.js:19:48)
在电话 (/Users/zhangwencai/qianduan/code ) /AwesomeProject/node_modules/connect/index.js:239:7)
在下一个(/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:183:5)
在下一个(/Users/zhangwencai/qianduan) /code/AwesomeProject/node_modules/connect/index.js:161:14)
在下一个(/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)
在下一个(/Users/zhangwencai) /qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)
在下一个(/Users/zhangwencai/qianduan/code/AwesomeProject/node_modules/connect/index.js:161:14)

您可以尝试将项目移动到另一条路径或尝试我的答案中描述的第二种方法

Problem solved, thank you

from cli.

itlingxiu avatar itlingxiu commented on June 14, 2024

删除第19行X-React-Native-Project-Root

@hw514352 这个方法挺管用的

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.