在 github 页面上部署我的 angular 网站,没有错误但无法正常工作
Deploy my angular website on github pages without error but not working
我按照 alligator 中的说明进行了操作。
- 我第一次做:
npm install -g angular-cli-ghpages
C:\Users\NEGU93\AppData\Roaming\npm\angular-cli-ghpages -> C:\Users\NEGU93\AppData\Roaming\npm\node_modules\angular-cli-ghpages\angular-cli-ghpages
C:\Users\NEGU93\AppData\Roaming\npm\ngh -> C:\Users\NEGU93\AppData\Roaming\npm\node_modules\angular-cli-ghpages\angular-cli-ghpages
npm WARN angular-cli-ghpages@0.6.2 requires a peer of @angular-devkit/architect@>=0.800.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular-cli-ghpages@0.6.2 requires a peer of @angular-devkit/core@>=8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular-cli-ghpages@0.6.2 requires a peer of @angular-devkit/schematics@>=8.0.0 but none is installed. You must install peer dependencies yourself.
2. angular-cli-ghpages@0.6.2
added 43 packages from 16 contributors in 4.064s
╭────────────────────────────────────────────────────────────────╮
│ │
│ New minor version of npm available! 6.13.4 -> 6.14.5 │
│ Changelog: https://github.com/npm/cli/releases/tag/v6.14.5 │
│ Run npm install -g npm to update! │
│ │
╰────────────────────────────────────────────────────────────────╯
- 然后我运行:
ng build --prod --base-href "jagustinbarrachina.github.io"
(我创建的 github 存储库是 https://github.com/NEGU93/jagustinbarrachina.github.io)。
Generating ES5 bundles for differential loading...
ES5 bundle generation complete.
chunk {0} runtime-es2015.1eba213af0b233498d9d.js (runtime) 1.45 kB [entry] [rendered]
chunk {0} runtime-es5.1eba213af0b233498d9d.js (runtime) 1.45 kB [entry] [rendered]
chunk {2} polyfills-es2015.690002c25ea8557bb4b0.js (polyfills) 36.1 kB [initial] [rendered]
chunk {3} polyfills-es5.9e286f6d9247438cbb02.js (polyfills-es5) 129 kB [initial] [rendered]
chunk {1} main-es2015.f6ff8052967ffdaf4a5b.js (main) 506 kB [initial] [rendered]
chunk {1} main-es5.f6ff8052967ffdaf4a5b.js (main) 581 kB [initial] [rendered]
chunk {4} styles.c29ceec637ed14ee7304.css (styles) 62.1 kB [initial] [rendered]
Date: 2020-05-20T08:13:25.911Z - Hash: 69b194328f29a17de042 - Time: 136730ms
WARNING in Exceeded maximum budget for W:/HardDiskDrive/Documentos/GitHub/Web-Development/my-website/src/app/timeline/timeline.component.css. Budget 6 kB was not met by 1.15
kB with a total of 7.15 kB.
- 最后,
ngh
returns:
index.html could not be copied to 404.html. This does not look like an angular-cli project?!
(Hint: are you sure that you have setup the directory correctly?)
Diagnostic info: ENOENT: no such file or directory, stat 'W:\HardDiskDrive\Documentos\GitHub\Web-Development\my-website\dist\index.html'
Uploading via git, please wait...
Successfully published via angular-cli-ghpages! Have a nice day!
然而,当我尝试访问“http://jagustinbarrachina.github.io/”时,我什么也没看到。不仅如此,我在 github 上的存储库仍然是空的。
我不知道该怎么办!我对 index.html 和 404.html 错误感到困扰,但如果我在我的 github 存储库中什么也没看到,我相信错误应该在此之前。当我添加路径时。
注意:我应该说我的代码实际上在我以前用来做版本控制的另一个git存储库中。我什么也没做,但我担心它们会互相干扰。
我按照发现 here 的方法 ngh --dir dist/my-website
解决了 index.html 的消息。
还是不行。
我现在使用的是我之前使用的基本存储库 (https://github.com/NEGU93/agustinbarrachina.github.io)。我刚刚重命名它(我听说我应该使用 .github.io
所以我为它重命名。我重复了所有步骤但仍然没有。我没有错误但仍然没有。
我连接到我的网站:https://github.com/NEGU93/agustinbarrachina.github.io。
当我单击 f12 查看控制台日志时,我得到:
GET https://agustinbarrachina.github.io/my-website/styles.083be7aca1b1a022cb0d.css net::ERR_ABORTED 404
negu93.github.io/:1 Access to script at 'https://agustinbarrachina.github.io/my-website/runtime-es2015.1eba213af0b233498d9d.js' from origin 'https://negu93.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
negu93.github.io/:20 GET https://agustinbarrachina.github.io/my-website/runtime-es2015.1eba213af0b233498d9d.js net::ERR_FAILED
Access to script at 'https://agustinbarrachina.github.io/my-website/polyfills-es2015.690002c25ea8557bb4b0.js' from origin 'https://negu93.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
negu93.github.io/:20 GET https://agustinbarrachina.github.io/my-website/polyfills-es2015.690002c25ea8557bb4b0.js net::ERR_FAILED
negu93.github.io/:1 Access to script at 'https://agustinbarrachina.github.io/my-website/main-es2015.8001cdba897b3e8b2c89.js' from origin 'https://negu93.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
negu93.github.io/:20 GET https://agustinbarrachina.github.io/my-website/main-es2015.8001cdba897b3e8b2c89.js net::ERR_FAILED
好的,我尝试了很多东西,显然它奏效了。
我看到 here 我需要添加 dist 文件夹。所以我把它从 gitignore 中删除了。
它还说我不应该保留源代码。所以我实际上创建了一个名为 gh-pages
的新存储库,我在这个 medium.
中遵循方法 2
我必须去设置存储库和 select 才能使用 gh-pages
分支。现在一切看起来都很好! https://negu93.github.io/agustinbarrachina/home
我按照 alligator 中的说明进行了操作。
- 我第一次做:
npm install -g angular-cli-ghpages
C:\Users\NEGU93\AppData\Roaming\npm\angular-cli-ghpages -> C:\Users\NEGU93\AppData\Roaming\npm\node_modules\angular-cli-ghpages\angular-cli-ghpages
C:\Users\NEGU93\AppData\Roaming\npm\ngh -> C:\Users\NEGU93\AppData\Roaming\npm\node_modules\angular-cli-ghpages\angular-cli-ghpages
npm WARN angular-cli-ghpages@0.6.2 requires a peer of @angular-devkit/architect@>=0.800.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular-cli-ghpages@0.6.2 requires a peer of @angular-devkit/core@>=8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular-cli-ghpages@0.6.2 requires a peer of @angular-devkit/schematics@>=8.0.0 but none is installed. You must install peer dependencies yourself.
2. angular-cli-ghpages@0.6.2
added 43 packages from 16 contributors in 4.064s
╭────────────────────────────────────────────────────────────────╮
│ │
│ New minor version of npm available! 6.13.4 -> 6.14.5 │
│ Changelog: https://github.com/npm/cli/releases/tag/v6.14.5 │
│ Run npm install -g npm to update! │
│ │
╰────────────────────────────────────────────────────────────────╯
- 然后我运行:
ng build --prod --base-href "jagustinbarrachina.github.io"
(我创建的 github 存储库是 https://github.com/NEGU93/jagustinbarrachina.github.io)。
Generating ES5 bundles for differential loading...
ES5 bundle generation complete.
chunk {0} runtime-es2015.1eba213af0b233498d9d.js (runtime) 1.45 kB [entry] [rendered]
chunk {0} runtime-es5.1eba213af0b233498d9d.js (runtime) 1.45 kB [entry] [rendered]
chunk {2} polyfills-es2015.690002c25ea8557bb4b0.js (polyfills) 36.1 kB [initial] [rendered]
chunk {3} polyfills-es5.9e286f6d9247438cbb02.js (polyfills-es5) 129 kB [initial] [rendered]
chunk {1} main-es2015.f6ff8052967ffdaf4a5b.js (main) 506 kB [initial] [rendered]
chunk {1} main-es5.f6ff8052967ffdaf4a5b.js (main) 581 kB [initial] [rendered]
chunk {4} styles.c29ceec637ed14ee7304.css (styles) 62.1 kB [initial] [rendered]
Date: 2020-05-20T08:13:25.911Z - Hash: 69b194328f29a17de042 - Time: 136730ms
WARNING in Exceeded maximum budget for W:/HardDiskDrive/Documentos/GitHub/Web-Development/my-website/src/app/timeline/timeline.component.css. Budget 6 kB was not met by 1.15
kB with a total of 7.15 kB.
- 最后,
ngh
returns:
index.html could not be copied to 404.html. This does not look like an angular-cli project?!
(Hint: are you sure that you have setup the directory correctly?)
Diagnostic info: ENOENT: no such file or directory, stat 'W:\HardDiskDrive\Documentos\GitHub\Web-Development\my-website\dist\index.html'
Uploading via git, please wait...
Successfully published via angular-cli-ghpages! Have a nice day!
然而,当我尝试访问“http://jagustinbarrachina.github.io/”时,我什么也没看到。不仅如此,我在 github 上的存储库仍然是空的。
我不知道该怎么办!我对 index.html 和 404.html 错误感到困扰,但如果我在我的 github 存储库中什么也没看到,我相信错误应该在此之前。当我添加路径时。
注意:我应该说我的代码实际上在我以前用来做版本控制的另一个git存储库中。我什么也没做,但我担心它们会互相干扰。
我按照发现 here 的方法 ngh --dir dist/my-website
解决了 index.html 的消息。
还是不行。
我现在使用的是我之前使用的基本存储库 (https://github.com/NEGU93/agustinbarrachina.github.io)。我刚刚重命名它(我听说我应该使用 .github.io
所以我为它重命名。我重复了所有步骤但仍然没有。我没有错误但仍然没有。
我连接到我的网站:https://github.com/NEGU93/agustinbarrachina.github.io。 当我单击 f12 查看控制台日志时,我得到:
GET https://agustinbarrachina.github.io/my-website/styles.083be7aca1b1a022cb0d.css net::ERR_ABORTED 404
negu93.github.io/:1 Access to script at 'https://agustinbarrachina.github.io/my-website/runtime-es2015.1eba213af0b233498d9d.js' from origin 'https://negu93.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
negu93.github.io/:20 GET https://agustinbarrachina.github.io/my-website/runtime-es2015.1eba213af0b233498d9d.js net::ERR_FAILED
Access to script at 'https://agustinbarrachina.github.io/my-website/polyfills-es2015.690002c25ea8557bb4b0.js' from origin 'https://negu93.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
negu93.github.io/:20 GET https://agustinbarrachina.github.io/my-website/polyfills-es2015.690002c25ea8557bb4b0.js net::ERR_FAILED
negu93.github.io/:1 Access to script at 'https://agustinbarrachina.github.io/my-website/main-es2015.8001cdba897b3e8b2c89.js' from origin 'https://negu93.github.io' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
negu93.github.io/:20 GET https://agustinbarrachina.github.io/my-website/main-es2015.8001cdba897b3e8b2c89.js net::ERR_FAILED
好的,我尝试了很多东西,显然它奏效了。
我看到 here 我需要添加 dist 文件夹。所以我把它从 gitignore 中删除了。
它还说我不应该保留源代码。所以我实际上创建了一个名为 gh-pages
的新存储库,我在这个 medium.
我必须去设置存储库和 select 才能使用 gh-pages
分支。现在一切看起来都很好! https://negu93.github.io/agustinbarrachina/home