gruntjs - Grunt build task for Angular4 Cannot find module '@angular/core/testing' -


i trying setup grunt build task angular 4 project , seeing module load errors when try run tasks. details of steps i've done -
1. went https://angular.io/guide/quickstart , used steps mentioned in quickstart create new angular4 app. tested , ensured working.
2. updated package.json file include following:

"grunt": "~0.4.5", "grunt-typescript": "^0.8.0", "grunt-contrib-copy": "~1.0.0", 
  1. added gruntfile.js following content:

    module.exports = function(grunt) {
    grunt.initconfig({
    typescript: {
    base: {
    src: [
    'src/app//.ts',
    ],
    dest: 'out/static/app.js',
    options: {
    target: 'es5',
    sourcemap: false,
    moduleresolution: 'node'
    }
    }
    }
    });
    grunt.loadnpmtasks('grunt-typescript');
    //grunt.loadnpmtasks('grunt-contrib-copy');
    grunt.registertask("default", ["typescript"]);
    grunt.registertask("build", ["typescript"]);
    };

  2. run grunt build.

when run grunt build, following in terminal:

running "typescript:base" (typescript) task >> src/app/app.component.spec.ts(1,32): error ts2307: cannot find module '@angular/core/testing'. >> src/app/app.component.spec.ts(5,1): error ts2304: cannot find name 'describe'. >> src/app/app.component.spec.ts(6,3): error ts2304: cannot find name 'beforeeach'. >> src/app/app.component.spec.ts(14,3): error ts2304: cannot find name 'it'. >> src/app/app.component.spec.ts(17,5): error ts2304: cannot find name 'expect'. >> src/app/app.component.spec.ts(20,3): error ts2304: cannot find name 'it'. >> src/app/app.component.spec.ts(23,5): error ts2304: cannot find name 'expect'. >> src/app/app.component.spec.ts(26,3): error ts2304: cannot find name 'it'. >> src/app/app.component.spec.ts(30,5): error ts2304: cannot find name 'expect'. >> src/app/app.component.ts(1,1): error ts1148: cannot compile modules unless '--module' flag provided. >> src/app/app.component.ts(1,27): error ts2307: cannot find module '@angular/core'. >> src/app/app.component.ts(8,14): error ts1219: experimental support decorators feature subject change in future release. specify '--experimentaldecorators' remove warning. >> src/app/app.module.ts(1,31): error ts2307: cannot find module '@angular/platform-browser'. >> src/app/app.module.ts(2,26): error ts2307: cannot find module '@angular/core'. >> src/app/app.module.ts(16,14): error ts1219: experimental support decorators feature subject change in future release. specify '--experimentaldecorators' remove warning. warning: task "typescript:base" failed. use --force continue. 

it seems other user has faced similar issue, had switch grunt-ts instead of using grunt-typescript. have suggestions on how working?

though have angular-cli (ng build) build angular 4 code, reason trying because going use in project has python backend code , grunt build tasks. merge build tasks existing gruntfile.js. newbie angular4 , typescript. learning work more on them , struggling issue resolved.

grunt-typescript issue posted here not resolved me. so, used grunt-ts suggested in https://stackoverflow.com/a/35121094/1040691. however, didn't generate files similar generated ng build. so, ended using webpack following guide https://angular.io/guide/webpack. generates results similar ng build.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -