could not local host after ng build with base href asssign

时间:2019-02-09 09:34:39

标签: javascript angular nginx

i have done ng build --base-href /emp/ after that i have link the dist folder to var/www/html and then i have configured my nginx default server , but7 when i localhost/emp/ its showing this error..

runtime.js:1 Uncaught SyntaxError: Unexpected token <
polyfills.js:1 Uncaught SyntaxError: Unexpected token <
styles.js:1 Uncaught SyntaxError: Unexpected token <
vendor.js:1 Uncaught SyntaxError: Unexpected token <
main.js:1 Uncaught SyntaxError: Unexpected token <

1 个答案:

答案 0 :(得分:1)

方法1:

在index.html文件中提及基本的href =“ / yourprojectfolderpath / dist /”

然后运行以下命令

ng build --prod。

打开浏览器并通过以下方式运行您的项目

localhost / yourprojectfolderpath / dist /

OR

方法2:

只需通过命令行设置基本路径

ng build --prod --base-href =“ / yourprojectfolderpath / dist /”

打开浏览器并通过以下方式运行您的项目

localhost / yourprojectfolderpath / dist /

我希望这会有用。