最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - URIError: Failed to decode param '<myusername><projectname>%PUBLIC_URL%manifest

programmeradmin0浏览0评论

I am trying to revive an old React app that I coded a year and a half ago.

I cloned it and installed all of the dependencies, but when I do 'npm start', it just loads a blank page and throws the error:

"URIError: Failed to decode param '///%PUBLIC_URL%/manifest.json'"

I am honestly not sure where to go from here.

Here is what my package.json looks like:

{
  "name": "nosmallstreamer",
  "version": "1.0.0",
  "description": "This project was bootstrapped with [Create React App]().",
  "main": "index.js",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "repository": {
    "type": "git",
    "url": "git+.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": ";
  },
  "homepage": ";,
  "dependencies": {
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^4.0.0"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Here is what my index.html looks like in the public folder:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <!-- <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> -->
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See /
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>

And here is what my manifest.json looks like in the public folder:

{
  "short_name": "React App",
  "name": "Create React App Sample",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "64x64 32x32 24x24 16x16",
      "type": "image/x-icon"
    }
  ],
  "start_url": ".",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}

Any help is appreciated!

I am trying to revive an old React app that I coded a year and a half ago.

I cloned it and installed all of the dependencies, but when I do 'npm start', it just loads a blank page and throws the error:

"URIError: Failed to decode param '///%PUBLIC_URL%/manifest.json'"

I am honestly not sure where to go from here.

Here is what my package.json looks like:

{
  "name": "nosmallstreamer",
  "version": "1.0.0",
  "description": "This project was bootstrapped with [Create React App](https://github./facebook/create-react-app).",
  "main": "index.js",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github./chaselancaster/nosmallstreamer-frontend.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github./chaselancaster/nosmallstreamer-frontend/issues"
  },
  "homepage": "https://github./chaselancaster/nosmallstreamer-frontend#readme",
  "dependencies": {
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^4.0.0"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Here is what my index.html looks like in the public folder:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <!-- <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> -->
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <!--
      manifest.json provides metadata used when your web app is installed on a
      user's mobile device or desktop. See https://developers.google./web/fundamentals/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
  </head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <!--
      This HTML file is a template.
      If you open it directly in the browser, you will see an empty page.

      You can add webfonts, meta tags, or analytics to this file.
      The build step will place the bundled scripts into the <body> tag.

      To begin the development, run `npm start` or `yarn start`.
      To create a production bundle, use `npm run build` or `yarn build`.
    -->
  </body>
</html>

And here is what my manifest.json looks like in the public folder:

{
  "short_name": "React App",
  "name": "Create React App Sample",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "64x64 32x32 24x24 16x16",
      "type": "image/x-icon"
    }
  ],
  "start_url": ".",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}

Any help is appreciated!

Share Improve this question edited Nov 20, 2020 at 19:25 Chase Lancaster asked Nov 20, 2020 at 2:06 Chase LancasterChase Lancaster 411 silver badge4 bronze badges 4
  • It looks like this was originally created with Create React App. I would assume it has a public folder. What are its contents? – Jordan Commented Nov 20, 2020 at 3:18
  • It contains the index.html and manifest.json! – Chase Lancaster Commented Nov 20, 2020 at 4:13
  • Could you edit your question and provide the index.html? – Jordan Commented Nov 20, 2020 at 17:10
  • Totally going to add it now! – Chase Lancaster Commented Nov 20, 2020 at 19:24
Add a ment  | 

2 Answers 2

Reset to default 5

Try changing your homepage in your package.json file to: "/" instead of using your GitHub repo's URL. react-scripts run (which is what npm start runs) seems to use the domain from the homepage as the root from which to serve the app.

In your index.html, try changing

<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

to:

<link rel="manifest" href="/public/manifest.json" />

This may be the only way to solve it without ejecting the project.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论