0

I can't get pass boot.js file when i run directly from: file:///C:/wamp/www/ngProject/index.html or from wamp : http://localhost/ngproject/

In develop mode it works with npm-start, but shouldn't it work with WAMP or just by running Index.html?

This is my system.js

  <script>
  System.config({
    packages: {        
      app: {
        format: 'register',
        defaultExtension: 'js'
      }
    }
  });
  System.import('app/boot')
        .then(null, console.error.bind(console));
</script>

When starting from wamp - Error: Unable to load script http://localhost/app/boot.js Error loading http://localhost/app/boot.js
When starting Index.html - Error: Unable to load script file:///app/boot.js Error loading file:///app/boot.js

2
  • have you tried checking the console for errors..?? Commented May 31, 2016 at 11:47
  • yes i edited the post with the errors. Commented May 31, 2016 at 12:19

3 Answers 3

1

Basically you always need a http server to run an Angular application.

Take a look at this question. There are some pretty solid answers on why a http server is needed.

Why do I need a HTTP-server to run Angular 2?

Regards,

Sign up to request clarification or add additional context in comments.

Comments

0

Try checking your path to boot.js. When starting from wamp - Error: Unable to load script http://localhost/app/boot.js

Error loading http://localhost/app/boot.js

The path here seems to be wrong,because your js file is located

@ http://localhost/ngProject/app/boot.js

Something like this might hep you

For wamp server try this

 System.config({
            baseURL: 'ngProject'
        });

System.import('app/boot')
        .then(null, console.error.bind(console));

3 Comments

The path is C:\wamp\www\ngProject\app\boot.js
Yes,The localhost is pointed to the C:\wamp\www\ folder right..?
Cris, Angular has to be hosted on the "server" so try to think of paths as "whateverURL"/path/to/file instead of how it actually is locally. I say that because often server setups MASK the local file system, which is often the case in Angular2 seeds. For example, my seed converts: /GIT/project/src/client/app to: localhost
0

So when you use npm-start there is likely a server setup for your project for your seed. This will have all the config settings for the server that runs in your seed package.

If you used the angular2-seed which I love but can be slightly complicated with its options, the settings are in: tools/config/seed-config.ts

What this does is MAP to your root folder to load files.

Wamp by default maps localhost to c:\www but you actually want it to map to c:\www\ngProject

Think about it like this,

When you load /ngProject/index.html It says, "Ok, I need to load boot.js which is located at /app/boot.js"

but it's really at /ngProject/app/boot.js and it fails

You can either change your system to load from /ngProject in all your configs, or what I reccomend is adjust your wamp settings.

Instructions from this SO Answer:

For wamp 2.5 on Windows, use a text editor, e.g. notepad++ to edit c:\wamp\bin\apache\apache2.4.9\conf\httpd.conf

  1. Change DocumentRoot "c:/wamp/www" to DocumentRoot "c:/my/new/path" (Note slash direction). This will change the location where files are served from (~Line 230).
  2. Change to (Note slash direction). This applies permissions from the old directory to the new one (~Line 252).

Another thing, is MANY of the seed's also have a "Production" build which will automatically convert to a relative/base root path structure. That is something I'd check too..

2 Comments

I tried changing DocumentRoot "c:/wamp/www/ngProject" <Directory "c:/wamp/www/ngProject"> and even DocumentRoot "c:/wamp/www/ngProject/app" <Directory "c:/wamp/www/ngProject"> but has no effect. Even my php projects work as usual from www folder.
I read about other ways (like Angular2 WebpackStarter or Angular2-Seed , that can turn all js into 1 and minify it, but i couldn't figure out how to make it work...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.