json-typescript-mapper icon indicating copy to clipboard operation
json-typescript-mapper copied to clipboard

json-typescript-mapper\libs\utils.ts is not part of the compilation output

Open huskercane opened this issue 7 years ago • 9 comments

Hello,

I see following trying to build angular 5 application. This used to work with angular 4.

C:\Work\assurant\XXXManagementApp [angular-5 ≡ +0 ~1 -0 !]> npm start

[email protected] start C:\Work\assurant\XXXManagementApp ng serve --proxy-config ./proxy.conf.js

** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ ** Date: 2017-11-13T14:12:31.724Z Hash: f6282ae4985825752bad Time: 24660ms chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered] chunk {main} main.bundle.js (main) 659 kB [initial] [rendered] chunk {polyfills} polyfills.bundle.js (polyfills) 971 kB [initial] [rendered] chunk {styles} styles.bundle.js (styles) 150 kB [initial] [rendered] chunk {vendor} vendor.bundle.js (vendor) 20.2 MB [initial] [rendered]

ERROR in ./node_modules/json-typescript-mapper/libs/utils.ts Module build failed: Error: C:\Work\assurant\XXXManagementApp\node_modules\json-typescript-mapper\libs\utils.ts is not part of the compilation output. Pl ease check the other error messages for details. at AngularCompilerPlugin.getCompiledFile (C:\Work\assurant\XXXManagementApp\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:629:23) at plugin.done.then (C:\Work\assurant\XXXManagementApp\node_modules@ngtools\webpack\src\loader.js:467:39) at at process._tickCallback (internal/process/next_tick.js:188:7) @ ./node_modules/json-typescript-mapper/index.js 3:14-37 @ ./src/app/metric.service.ts @ ./src/app/app.module.ts @ ./src/main.ts @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

webpack: Failed to compile.

I found this link that could explain https://github.com/angular/angular-cli/issues/8284

so I tried adding include to tsconfig.json but that did not solve it

huskercane avatar Nov 13 '17 14:11 huskercane

@huskercane - I got the same error (also using angular 5) and have resolved it. You are onto the right track with the include.
Here is my working tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  },
  "include": [
    "src/**/*",
    "node_modules/json-typescript-mapper/libs/utils.ts"
  ]
}

So I've basically just add the include section. You need to be careful not to put it at the wrong level.

Reading around the issue, the above solution is a workaround. The json-typescript-mapper should not be shipping the utils.ts file to npm, the utils.js and utils.d.ts is sufficient. Another workaround is therefore to delete node_modules/json-typescript-mapper/libs/utils.ts - however I expect the file may come back on a npm clean or update.

owennewo avatar Nov 14 '17 22:11 owennewo

@owennewo your suggestion does solve the problem. This is proper work around thank you.

huskercane avatar Nov 20 '17 14:11 huskercane

It's not helped me

Sir-J avatar Dec 02 '17 12:12 Sir-J

I tried @owennewo's solution, but got:

error TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["src/**/*","node_modules/json-typescript-mapper/libs/utils.ts"]' and 'exclude' paths were '["../dist/out-tsc"]'.

BBaysinger avatar Dec 21 '17 06:12 BBaysinger

Ok, I fixed that by adding ../ to both paths.

BBaysinger avatar Dec 21 '17 06:12 BBaysinger

I'm getting the same error while running ng-test, even though I have added in tsconfig file.

{ "compileOnSave": false, "compilerOptions": { "module": "commonjs", "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", "typeRoots": [ "node_modules/@types" ], "lib": [ "es2017", "dom" ] }, "exclude": [ "node_modules" ], "include": [ "src/**/*", "node_modules/json-typescript-mapper/libs/utils.ts" ] }

I don't have any issue while running the application but it fails while I run the test cases. Typescript version Used: "typescript": "~2.5.3"

RROR in ./node_modules/json-typescript-mapper/libs/utils.ts Module build failed: Error: ..\node_modules\json-typescript-mapper\libs\utils.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).

I also added the "node_modules/json-typescript-mapper/libs/utils.ts" in 'tsconfig.spec.json but still facing the same issue.

Rajashreegr avatar Apr 12 '18 15:04 Rajashreegr

The above error was actually my issue. I solved it by correcting the utils.ts path in tsconfig.spec.json file. "../node_modules/json-typescript-mapper/libs/utils.ts" (I missed ../ before).

Rajashreegr avatar Apr 12 '18 15:04 Rajashreegr

I still getting this problem, please somebody help:

tsconfig:

{ "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app", "baseUrl": "./", "module": "es2015", "types": [], "experimentalDecorators": true, "emitDecoratorMetadata": true }, "include": [ "src//*", "../node_modules/json-typescript-mapper/libs/utils.ts" ], "exclude": [ "test.ts", "/*.spec.ts" ] }

ERROR;

ERROR in ./src/main.ts Module build failed: Error: C:...\src\main.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. at AngularCompilerPlugin.getCompiledFile (C:...\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:674:23) at plugin.done.then (C:...\node_modules@ngtools\webpack\src\loader.js:467:39) at at process._tickCallback (internal/process/next_tick.js:188:7) ERROR in ./src/polyfills.ts Module build failed: Error: C:...\src\polyfills.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. at AngularCompilerPlugin.getCompiledFile (C:...\node_modules@ngtools\webpack\src\angular_compiler_plugin.js:674:23) at plugin.done.then (C:...\node_modules@ngtools\webpack\src\loader.js:467:39) at

webpack: Failed to compile.

DiegoVenancioVieira avatar May 01 '18 01:05 DiegoVenancioVieira

Working for me { "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app", "types": [], "experimentalDecorators": true, "emitDecoratorMetadata": true }, "include":[ "../src//*", "../node_modules/json-typescript-mapper2/libs/utils.ts" ], "exclude": [ "test.ts", "/*.spec.ts" ]

eddie007bkk avatar Feb 16 '19 08:02 eddie007bkk