FountainJS / generator-fountain-webapp

Yeoman 'fountain' generator to start a webapp
http://fountainjs.io
MIT License
963 stars 67 forks source link

angular 2 npm run build complaining routes.ts not found #81

Open dereklin opened 8 years ago

dereklin commented 8 years ago

routes.ts is in [root]/app folder But the build process is looking for it at the root folder:

Here is my .yo-rc.json

{
  "generator-fountain-angular2": {
    "version": "0.6.0",
    "props": {
      "framework": "angular2",
      "modules": "systemjs",
      "js": "typescript",
      "css": "css",
      "resolved": "C:\\Users\\Derek\\AppData\\Roaming\\npm\\node_modules\\generator-fountain-webapp\\node_modules\\generator-fountain-angular2\\generators\\app\\index.js",
      "namespace": "fountain-angular2",
      "argv": {
        "remain": [],
        "cooked": [],
        "original": []
      },
      "skip-cache": false,
      "skip-install": false,
      "sample": "hello",
      "router": "router"
    }
  }
}

Here are the error messages when I run npm run build:

[00:36:24] Starting 'systemjs'...
[00:36:24] Finished 'other' after 735 ms
[00:36:25] 'systemjs' errored after 1.35 s
[00:36:25] Error on fetch for routes.ts at file:///c:/Users/Derek/sandbox/fountain-webapp/danshui/routes.ts
        Loading .tmp\templates\index.ts
        Error: ENOENT: no such file or directory, open 'c:\Users\Derek\sandbox\fountain-webapp\danshui\routes.ts'
    at Error (native)
Unhandled rejection Error: Uncaught, unspecified "error" event. ([object Object])
    at Gulp.emit (events.js:144:17)
    at Gulp.src.emit (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\fwd\index.js:31:10)
    at Object.error (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\undertaker\lib\helpers\createExtensions.js:61:10)
    at handler (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\now-and-later\lib\mapSeries.js:43:14)
    at f (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\once\once.js:17:25)
    at f (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\once\once.js:17:25)
    at done (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\async-done\index.js:24:15)
    at bound (domain.js:280:14)
    at runBound (domain.js:293:12)
    at tryCatcher (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\bluebird\js\release\promise.js:504:31)
    at Promise._settlePromise (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\bluebird\js\release\promise.js:561:18)
    at Promise._settlePromise0 (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\bluebird\js\release\promise.js:606:10)
    at Promise._settlePromises (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\bluebird\js\release\promise.js:681:18)
    at Async._drainQueue (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\bluebird\js\release\async.js:138:16)
    at Async._drainQueues (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\bluebird\js\release\async.js:148:10)
    at Immediate.Async.drainQueues [as _onImmediate] (c:\Users\Derek\sandbox\fountain-webapp\danshui\node_modules\bluebird\js\release\async.js:17:14)
    at processImmediate [as _immediateCallback] (timers.js:368:17)

[00:36:27] The following tasks did not complete: default, build, <parallel>, systemjs
[00:36:27] Did you forget to signal async completion?
micaelmbagira commented 8 years ago

Did you retry to generate a project ? Could you send a github link, because I cannot reproduce it ?

dereklin commented 8 years ago

@micaelmbagira Here is my github link: https://github.com/dereklin/ng2-danshui

I tried to run npm run build

micaelmbagira commented 8 years ago

Well, I cloned the project and ran npm install and ./node_modules/.bin/jspm install and then npm run build or gulp serve, everything works fine.

dereklin commented 8 years ago

I am using windows 10, node v4.4.7, npm 3.10.5

dereklin commented 8 years ago

using webpack works, but systemjs doesn't

shenglol commented 8 years ago

I got the same problem using angular2 + systemjs + typescript.

micaelmbagira commented 8 years ago

@dereklin Can you make a fresh clone of the repo you sent and then run:

dereklin commented 8 years ago

@micaelmbagira same problem

[00:17:50] Finished 'other' after 405 ms
[00:17:50] Finished 'replaceTemplates' after 417 ms
[00:17:50] Starting 'systemjs'...
[00:17:52] 'systemjs' errored after 1.39 s
[00:17:52] Error on fetch for routes.ts at file:///c:/Users/Derek/sandbox/fountain/ng2-danshui/routes.ts
        Loading .tmp\templates\index.ts
        Error: ENOENT: no such file or directory, open 'c:\Users\Derek\sandbox\fountain\ng2-danshui\routes.ts'
    at Error (native)
Unhandled rejection Error: Uncaught, unspecified "error" event. ([object Object])
    at Gulp.emit (events.js:144:17)
    at Gulp.src.emit (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\fwd\index.js:31:10)
    at Object.error (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\undertaker\lib\helpers\createExtensions.js:61:10)
    at handler (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\now-and-later\lib\mapSeries.js:43:14)
    at f (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\once\once.js:17:25)
    at f (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\once\once.js:17:25)
    at done (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\async-done\index.js:24:15)
    at bound (domain.js:287:14)
    at runBound (domain.js:300:12)
    at tryCatcher (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\bluebird\js\release\promise.js:504:31)
    at Promise._settlePromise (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\bluebird\js\release\promise.js:561:18)
    at Promise._settlePromise0 (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\bluebird\js\release\promise.js:606:10)
    at Promise._settlePromises (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\bluebird\js\release\promise.js:681:18)
    at Async._drainQueue (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\bluebird\js\release\async.js:138:16)
    at Async._drainQueues (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\bluebird\js\release\async.js:148:10)
    at Immediate.Async.drainQueues [as _onImmediate] (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\bluebird\js\release\async.js:17:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

[00:17:53] The following tasks did not complete: default, build, <parallel>, systemjs
[00:17:53] Did you forget to signal async completion?

note, the second step is: "./node_modules/.bin/jspm" install

micaelmbagira commented 8 years ago

Obviously, there is an issue regarding the fact SystemJS is looking for routes.ts in ng2-danshui while it's in ng2-danshui/src. Still, I cannot reproduce it... Are you able to try on another OS ?

shenglol commented 8 years ago

@dereklin @micaelmbagira It seems that this is an issue with file paths on Windows. I just changed the following code ingulp_tasks/systemjs.js from

conf.path.tmp('templates/index.ts'),

to

'.tmp/templates/index.ts',

and the problem is gone.

SystemJS builder takes an input module name as argument, which must use / in paths not . However, conf.path.tmp('templates/index.ts') will return '.tmp\templates\index.ts' on Windows.

dereklin commented 8 years ago

@msshli You did this right?:

  builder.buildStatic(
    // conf.path.tmp('templates/index.ts'),
    '.tmp/templates/index.ts',
    conf.path.tmp('index.js'),

I am now getting this error:

[22:01:50] Finished 'systemjs' after 6.58 s
[22:01:50] Starting 'build'...
[22:01:50] 'build' errored after 190 ms
[22:01:50] Error: Error: File not found with singular glob: c:\Users\Derek\sandbox\fountain\ng2-danshui\.tmp\jspm_packages\system.js
    at DestroyableTransform.<anonymous> (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\gulp-useref\lib\streamManager.js:90:36)
    at emitOne (events.js:82:20)
    at DestroyableTransform.emit (events.js:169:7)
    at emitOne (events.js:82:20)
    at Through2.emit (events.js:169:7)
    at OrderedStreams.<anonymous> (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\glob-stream\index.js:138:20)
    at emitOne (events.js:77:13)
    at OrderedStreams.emit (events.js:169:7)
    at emitOne (events.js:77:13)
    at DestroyableTransform.emit (events.js:169:7)
    at Glob.<anonymous> (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\glob-stream\index.js:38:16)
    at Glob.g (events.js:260:16)
    at emitOne (events.js:77:13)
    at Glob.emit (events.js:169:7)
    at Glob._finish (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\glob-stream\node_modules\glob\glob.js:172:8)
    at done (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\glob-stream\node_modules\glob\glob.js:159:12)
    at Glob._processSimple2 (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\glob-stream\node_modules\glob\glob.js:652:12)
    at c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\glob-stream\node_modules\glob\glob.js:640:10
    at Glob._stat2 (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\glob-stream\node_modules\glob\glob.js:736:12)
    at lstatcb_ (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\glob-stream\node_modules\glob\glob.js:728:12)
    at RES (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\inflight\inflight.js:23:14)
    at f (c:\Users\Derek\sandbox\fountain\ng2-danshui\node_modules\once\once.js:17:25)
[22:01:50] 'build' errored after 6.94 s
[22:01:50] 'default' errored after 7.01 s
micaelmbagira commented 8 years ago

@msshli it seems you're right https://github.com/systemjs/builder/issues/621

shenglol commented 8 years ago

@micaelmbagira I didn't have this problem before, but today it just showed up suddenly... It turned out there's something wrong with gulp-replace. In updateIndexHtml in systemjs.js, try replace the following regular expression

/<script src="jspm_packages\/system.js">[\s\S]*System.import.*\n\s*<\/script>/

with

/<script src="jspm_packages\/system.js">[\s\S]*<\/script>/

The previous one seems to be correct but somehow gulp-replace fails to replace the following code in src/index.html:

<script src="jspm_packages/system.js"></script>
<script src="jspm.browser.js"></script>
<script src="jspm.config.js"></script>

<script>
    System.import('src/index.ts');
</script>

I don't know if it is another Windows issue. Anyway, hope this help :)

Endellur commented 8 years ago

To get SystemJS/jspm with Angular 1 working I had to modify src/index.js to include the src directory in the imports on Windows:

import techsModule from 'src/app/techs/index.js';
import 'angular-ui-router';
import routesConfig from 'src/routes.js';

import main from 'src/app/main.js';
import header from 'src/app/header.js';
import title from 'src/app/title.js';
import footer from 'src/app/footer.js';

It appears the project root is being used instead of the current directory for imports. I posted here because the file not found error was similar but it may be a separate issue.