Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have an error when executing ionic serve

When I execute ionic serve, it shows the following errors:

Refused to load the image 'http://localhost:8100/favicon.ico' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.

Failed to load resource: the server responded with a status of 404 (Not Found)

How can I solve this?

like image 493
Norm Avatar asked May 22 '19 03:05

Norm


People also ask

How do you serve an ionic app?

By default, ionic serve boots up a development server on localhost . To serve to your LAN, specify the --external option, which will use all network interfaces and print the external address(es) on which your app is being served. Try the --lab option to see multiple platforms at once. ionic serve uses the Angular CLI.

How do I run an ionic app in another port?

If you want to specify the ports themselves, you can pass additional option arguments when you run ionic serve like — port|-p for an specific web server port. If you try ionic serve -p 8200 -i 35730, the app runs perfectly with the custom web server and livereload port in your browser.

How to use ionic serve to serve an app?

To serve to your LAN, specify the --external option, which will use all network interfaces and print the external address (es) on which your app is being served. Try the --lab option to see multiple platforms at once. ionic serve uses the Angular CLI. Use ng serve --help to list all Angular CLI options for serving your app.

How to bind ionic serve to localhost?

By default, ionic serve boots up a development server on all network interfaces and prints the external address (es) on which your app is being served. It also broadcasts your app to the Ionic DevApp on your network. To disable the DevApp and bind to localhost, use --local. Try the --lab option to see multiple platforms at once.

How does ionic serve work in Eclipse?

Easily spin up a development server which launches in your browser. It watches for changes in your source files and automatically reloads with the updated build. By default, ionic serve boots up a development server on all network interfaces and prints the external address (es) on which your app is being served.

Why can't I use the ionic command in shell script?

The shell no longer recognizes the "ionic" command. That was the result of an aborted installation. Now fixed. Serve.loadSettings - You must pass a project object to pull out project specific settings from


1 Answers

I had the same error message.

Looking through the logs printed when doing

ionic serve

showed me a bunch of errors, all similar to this


[ng] ERROR in ./src/global.scss (./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/raw-css-loader.js!./node_modules/postcss-loader/src??embedded!./node_modules/sass-loader/lib/loader.js??ref--14-3!./src/global.scss)

[ng] Module build failed (from ./node_modules/sass-loader/lib/loader.js):

[ng] Error: Cannot find module 'node-sass'

[ng] Require stack:

This lead me to get the application up and running again by

npm install node-sass --save

The compilation process is sometimes spitting out rather confusing error messages from time to time, but with a little digging one can start guessing where to start poking

like image 55
Mattias Avatar answered Oct 24 '22 08:10

Mattias