Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 Error Trying to Load the Package #21

Closed
kingws opened this issue Feb 2, 2017 · 4 comments
Closed

404 Error Trying to Load the Package #21

kingws opened this issue Feb 2, 2017 · 4 comments

Comments

@kingws
Copy link

kingws commented Feb 2, 2017

I keep getting a 404 trying to load the markdown module into my application. I understand the TypeScript module resolution behaves much like Node in that it will traverse directories up the stack until if finds the module it's looking for (looking in module.ts, package.json, or index.ts respectively). With that being said, I've added your package to my project (which is essentially the angular2 quickstart at its' base), but I'm getting a 404 on the node_modules/angular2-markdown GET call. Here's my setup (only showing what's applicable to the issue) :

tsconfig.json

`"compilerOptions": {
    ......
   "moduleResolution": "node".
    ......
}`

systemjs.config.js

`(function (global) {
    System.config({
        paths: {
            // paths serve as alias
            'npm:': 'node_modules/'
        },
        // map tells the System loader where to look for things
        map: {
            ......
            'angular2-markdown': 'npm:angular2-markdown'
            .......
        });
})(this);`

package.json

`{
    ......
    "dependencies": {
        ......
        "angular2-markdown": "^1.3.5",
        ......
}`

app.module.js

`import { MarkdownModule } from 'angular2-markdown';
......
@NgModule({
    declarations: [
        ......
    ],
    imports:    [
        ......,
        MarkdownModule.forRoot()
    ],
    ......
export class AppModule { }`

The angular2-markdown package sits in the 'node_modules/angular2-markdown' directory. Inside the root of that package is the index.ts class. Since the package.json doesn't contain a "typings" property, the compiler should be using the index.ts, which contains:

index.ts

export * from './src/app/markdown/markdown.module';
export * from './src/app/markdown/markdown.component';

So, as you can see, the 'angular2-markdown' package is aliased to the node_modules directory in my project, but unfortunately when I try and grab the MarkdownModule I get the following error in my console:

GET http://localhost:3000/node_modules/angular2-markdown/ 404 (Not Found)

It looks as if the compiler isn't actually reading the index.ts. I've tried several things to try and brute force this thing to work. For example:

systemjs.config

  • Map directly to 'node_modules/angular2-markdown/index'
  • Map directly to 'node_modules/angular2-markdown/index.ts'

app.module.ts

  • Import the module directly from 'node_modules/angular2-markdown/index'
  • Import the module directly from 'node_modules/angular2-markdown/index.ts' (which I knew obviously wouldn't work, but at this point I'm out of ideas)

Suffice it to say none of that worked and I'm not sure what the problem is. Can anyone shed some light on this issue for me? I just started using Angular2, but I feel like this is more of a build issue than a library issue. Thanks in advance.

@kingws
Copy link
Author

kingws commented Feb 8, 2017

Any updates on this?

@Cognition3142
Copy link

I'm hitting the same issue. @kingws did you manage to fix it?

@kingws
Copy link
Author

kingws commented Feb 16, 2017

Negative @Cognition3142. I changed my project to use webpack2 trying to fix this issue. All that did was opened a whole different set of problems with this package so I canned it. I submitted this issue two weeks ago and haven't heard a single thing so I gave up on it. I ended up using the markdown-loader in my web pack config:

{ test: /\.md$/, use: [ 'html-loader', 'markdown-loader' ] },

Then adding a function to my component:

getReadme() { let html = require('./README.md'); if (html) { return html; } }

This is nice. If the README is there it's displayed, otherwise it's skipped because of the *ngif in the template:

<div *ngIf="getReadme()" class="markdown-container" [innerHtml]="getReadme()"></div>

I hope this helps you out.

@dimpu
Copy link
Owner

dimpu commented Feb 19, 2017

I have added "umd" to the package please upgrade it to latest version to fix this issu.e

@dimpu dimpu closed this as completed Feb 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants