cstefanache / angular2-img-cropper

Angular 2 Image Cropper
MIT License
364 stars 135 forks source link

File is not under 'rootDir' #102

Closed NaLLiFFuNT closed 7 years ago

NaLLiFFuNT commented 7 years ago

I just installed and tried to use your croper. When i started to build my project i saw the following error:

File 'projectRoot/node_modules/ng2-img-cropper/src/model/point.ts' is not under 'rootDir' '/projectRoot/frontend/src'. 'rootDir' is expected to contain all source files.

travislaynewilson commented 7 years ago

I'm experiencing the same thing when using AOT compilation with Angular 2 2.4.1, Typescript 2.1.4 and the Image Cropper (v.0.7.6).

I suspect that rootDir is the issue on some level.

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "",
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "declaration": true,
    "noImplicitAny": false,
    "sourceMap": true,
    "mapRoot": "",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "outDir": "./build",
    "rootDir": "./src/app",
    "skipLibCheck": true,
    "allowSyntheticDefaultImports": true,
    "noEmitHelpers": true,
    "strictNullChecks": false,
    "paths": {},
    "typeRoots": [
      "./node_modules/@types"
    ],
    "types": [
      "node",
      "selenium-webdriver",
      "source-map",
      "uglify-js",
      "webpack"
    ],
    "lib": [
      "dom",
      "es2015"
    ]
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "exclude": [
    "node_modules",
    "dist",
    "**/*.ngfactory.ts",
    "**/*.shim.ts",
    "src/app/main*.ts",
    "src/app/polyfills.ts",
    "src/app/vendor.ts"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "angularCompilerOptions": {
    "genDir": ".",
    "entryModule": "src/app/app.module#AppModule"
  }
}
travislaynewilson commented 7 years ago

The issue seems to have appeared in other libraries as well (https://github.com/valor-software/ng2-select/issues/161).

The problem is that the NPM package contains *.ts files. There's no reason to deploy your *.ts files with the package, so I would recommend using your .npmignore file to ignore them when packaging your app.

A quick-and-dirty fix for those with this issue would be to delete the *.ts and *.ngsummary.json files from your node_modules/ng2-img-cropper folder. Be sure to clean the src folder too!

This solution worked for me.

cstefanache commented 7 years ago

ts files removed with 0.8.2 - please test