angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.77k stars 11.97k forks source link

Unhandled Promise Rejection (404 Not Found) loading markdown-it . #529

Closed dessalines closed 8 years ago

dessalines commented 8 years ago

I can't seem to get the library markdown-it to work. I've installed it through npm, and the typings, so there are no typescript compiler errors. ng-serve runs fine with no errors, but I get the following error in the console:

Unhandled Promise rejection: "XHR error (404 Not Found) loading http://localhost:4200/markdown-it
    Error loading http://localhost:4200/markdown-it as "markdown-it" from http://localhost:4200/app/ang-cli-test.js" ; Zone: <root> ; Task: Promise.then ; Value: Error: XHR error (404 Not Found) loading http://localhost:4200/markdown-it

Which tells me that angular-cli isn't bundling it correctly.

My import statement is: import * as markdownIt from 'markdown-it';, and I said, the typescript compiler is recognizing it.

Env:

~/git/ang-cli-test$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/user-guide/#watchman for more info.
angular-cli: 0.0.33
node: 5.10.1
os: linux x64

Thanks.

jkuri commented 8 years ago

Hey @tchoulihan. Did you follow the steps that are provided on the wiki?

dessalines commented 8 years ago

@jkuri , I didn't see that. I assumed it was just a problem with this library, since I randomly tried ng install moment and I didn't need to do any of that.

Actually I just looked over the 3rd party libs page, it looks like its out of date. For example, the system-config.js file is used now as opposed to the script, and the syntax looks quite different.

jkuri commented 8 years ago

@tchoulihan yes, please update your angular-cli version, seems like you are using very outdated one.

dessalines commented 8 years ago

My ang-version is

angular-cli: 0.0.33
node: 5.10.1
os: linux x64

Version 0.0.34 just got pushed 5 hours ago.

Are the docs correct for 0.0.34, and not 0.0.33?

dessalines commented 8 years ago

I can verify that the wiki docs are not correct for this new version, the system-config.js is still being used.. I still need help with this issue.

jkuri commented 8 years ago

Sorry, my mistake then, I will update the wiki docs and let you know.

dessalines commented 8 years ago

No problem, thanks.

jkuri commented 8 years ago

@tchoulihan I just updated the docs, please let me know if now works for you. Thanks for notify about outdated docs.

dessalines commented 8 years ago

Thanks!

dessalines commented 8 years ago

@jkuri Tried the updated docs, also didn't work, getting the same error as above. The broccoli compiler seems to work fine, but the console in the browser gives the error:

Unhandled Promise rejection: "XHR error (404 Not Found) loading http://localhost:4200/vendor/markdown-it/markdown.js
    Error loading http://localhost:4200/vendor/markdown-it/markdown.js as "markdown-it" from http://localhost:4200/app/ang-cli-test-2.component.js"

The issue seems to be in the system-config.ts file:

// Add your custom SystemJS configuration here.
export const config: any = {
  packages: Object.assign({
    // Add your custom SystemJS packages here.
  }, createPackageConfig(barrels)),
  map: {
    'markdown-it': 'vendor/markdown-it/markdown.js' 
  }
};

I've tried lots of combinations of this. The actual js file is located at node_modules/markdown-it/dist/markdown.js, but I've tried that, and many other combinations such as markdown-it/dist/markdown.js, but they all give the same error.

jkuri commented 8 years ago

@tchoulihan the docs includes the examples, you must set paths that fits your library, I guess in your case would be;

vendorNpmFiles: ['markdown-it/dist/markdown.js']
map: {
  'markdown-it': 'vendor/markdown-it/dist/markdown.js' 
}

Just check the paths where the .js file is located.

dessalines commented 8 years ago

Oops my bad, I didn't realize the location was right there in the vendor folder. Sorry about that. It would be useful to include that in the docs for adding 3rd party libraries, since each one might be in a different location.

jkuri commented 8 years ago

No problem, does it works now for you?

dessalines commented 8 years ago

Oops sorry, should've said that it does. Thanks a bunch.

omeryounus commented 8 years ago

Hi I am getting the same error. Is there any solution?

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.