Angular-cli: Getting the error (Emitted value instead of an instance of Error) Cannot find source file 'compiler.es5.ts' after ejecting webpack.config.js

Created on 24 Jul 2017  路  8Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.2.1
node: 6.9.5
os: win32 x64

Repro steps.

$ ng new somerepo
$ cd somerepo
$ npm i
$ ng eject
$ npm start

The log given by the failure.

WARNING in /@angular/compiler/@angular/compiler.es5.js
(Emitted value instead of an instance of Error) Cannot find source file 'compiler.es5.ts': Error: Can't resolve './compiler.es5.ts' in 'D:\Projects\innovation-studio-packages\packages\innovation-studio\node_modules\@angular\compi
ler\@angular'
@ ./~/@angular/platform-browser-dynamic/@angular/platform-browser-dynamic.es5.js 7:0-72
@ ./src/main.ts
@ multi (webpack)-dev-server/client?http://localhost:4200 ./src/main.ts

Desired functionality.

No errors

Mention any other details that might be useful.

angulacli medium inconvenient bufix

Most helpful comment

This seems to be related to the "source-map-loader" where the exclude-statement via regex doesnt work properly...
You can fix this by manually by editing the ejected webpack.config.json

"module": {
    "rules": [
      {
        "enforce": "pre",
        "test": /\.js$/,
        "loader": "source-map-loader",
        "exclude": [
          // instead of /\/node_modules\//
          path.join(process.cwd(), 'node_modules')
        ]
      },

Can you confirm this solves your problem? Will prepare an pull-request for this then...

Seems related to https://github.com/angular/angular-cli/issues/6870

All 8 comments

This seems to be related to the "source-map-loader" where the exclude-statement via regex doesnt work properly...
You can fix this by manually by editing the ejected webpack.config.json

"module": {
    "rules": [
      {
        "enforce": "pre",
        "test": /\.js$/,
        "loader": "source-map-loader",
        "exclude": [
          // instead of /\/node_modules\//
          path.join(process.cwd(), 'node_modules')
        ]
      },

Can you confirm this solves your problem? Will prepare an pull-request for this then...

Seems related to https://github.com/angular/angular-cli/issues/6870

@christianscharr Thanks, works perfect for me! 馃憤

I am still getting this error on @angular/cli version 1.4.5 (@angular/compiler version 4.3.6):

WARNING in ./node_modules/@angular/compiler/@angular/compiler.es5.js
(Emitted value instead of an instance of Error) Cannot find source file 'compiler.es5.ts': Error: Can't resolve './compiler.es5.ts' in 'C:\folderName\src\node_modules\@angular\compiler\@angular'
 @ ./node_modules/@angular/platform-browser-dynamic/@angular/platform-browser-dynamic.es5.js 7:0-72
 @ ./main/main.ts
 @ multi (webpack)-dev-server/client?http://localhost.ms.com:4100 ./main/main.ts

looking in the relevant folder I only see js files in there, there are no ts files...

I'm also still getting this error. I'm using

    "@angular/cli": "^1.6.2",
    "@angular/compiler": "^5.1.2",
    "@angular/compiler-cli": "^5.1.2",

In my case, it seems to be triggered by a font resource:

WARNING in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/styles.scss
(Emitted value instead of an instance of Error) postcss-url: /Users/zakdances/projects/MyProject/web/site/MyProject/src/styles.scss:4:3: Can't read file'/Users/zakdances/projects/MyProject/web/site/MyProject/src/assets/fonts/My%20Font%20Medium%20Condensed%20Italic.otf', ignoring
NonErrorEmittedError: (Emitted value instead of an instance of Error) postcss-url: /Users/zakdances/projects/MyProject/web/site/MyProject/src/styles.scss:4:3: Can't read file '/Users/zakdances/projects/MyProject/web/site/MyProject/src/assets/fonts/My%20Font%20Medium%20Condensed%20Italic.otf', ignoring
    at Object.emitWarning (/Users/zakdances/projects/MyProject/web/site/MyProject/node_modules/webpack/lib/NormalModule.js:117:16)
    at result.warnings.forEach (/Users/zakdances/projects/MyProject/web/site/MyProject/node_modules/postcss-loader/lib/index.js:149:49)
    at Array.forEach (<anonymous>)
    at postcss.process.then (/Users/zakdances/projects/MyProject/web/site/MyProject/node_modules/postcss-loader/lib/index.js:149:27)
    at <anonymous>
 @ ./src/styles.scss 4:14-191
 @ multi ./src/styles.scss ./src/app/theme-1.scss

In my case, looks like the package ngx-quill has problems with its source maps so exclude the package instead of excluding the whole node_modules.

I had the same problem with Reflect.ts.
Module Warning (from ./node_modules/source-map-loader/index.js):; (Emitted value instead of an instance of Error) Cannot find source file 'Reflect.ts': Error: Can't resolve './Reflect.ts'

I solved with @christianscharr solution.

eject functionality is no longer available in the latest version (6.x+). For custom webpack configurations the following unofficial add-on is a suggested solution: https://github.com/manfredsteyer/ngx-build-plus

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings