Skip to content

@angular@8.2.0-next.0: ERROR in ENOTDIR: not a directory, scandir *****/index.ts #31424

Closed

Description

@julianobrasil

🐞 bug report

Affected Package

Angular 8.2.0-next.0

I wasn't able to compile an Ivy project using @angular@8.2.0-next.0 with Ivy enabled. It compiles using @angular 8.1.0

Is this a regression?

Yes, the previous version in which this bug was not present was: Angular 8.1.0-next.3

Description

I'm trying to compile an existing project (@nrwl recommended structure) using Ivy

🔬 Minimal Reproduction

🔥 Exception or Error


ERROR in ENOTDIR: not a directory, scandir 'E:/Users/Juliano/Documents/Projetos/sa/sa-ui/saWorkspace/libs/issue-tracker/data-access/model/src/index.ts'

----------------------------------------------

10 silly lifecycle sa@0.0.0~build-pre: Args: [
10 silly lifecycle   '/d /s /c',
10 silly lifecycle   'ng build --configuration=preproduction --base-href /tutoria/'
10 silly lifecycle ]
11 silly lifecycle sa@0.0.0~build-pre: Returned: code: 1  signal: null
12 info lifecycle sa@0.0.0~build-pre: Failed to exec build-pre script
13 verbose stack Error: sa@0.0.0 build-pre: `ng build --configuration=preproduction --base-href /tutoria/`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter. (C:\Users\Juliano\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:200:13)
13 verbose stack     at ChildProcess. (C:\Users\Juliano\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:200:13)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid sa@0.0.0
15 verbose cwd E:\Users\Juliano\Documents\Projetos\sa\sa-ui\saWorkspace
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Juliano\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build-pre"
18 verbose node v12.3.1
19 verbose npm  v6.9.2
20 error code ELIFECYCLE
21 error errno 1
22 error sa@0.0.0 build-pre: `ng build --configuration=preproduction --base-href /tutoria/`
22 error Exit status 1
23 error Failed at the sa@0.0.0 build-pre script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Activity

  1. michael42 commented on Jul 5, 2019

    @michael42

    This might be the same issue that I get when setting enableIvy: true in my project, but I find the description here pretty vague.

    tsconfig.json:

    {
      "compilerOptions": {
         // ...
        "paths": {"config": ["src/config.dev.ts"]}
      },
      "angularCompilerOptions": { "enableIvy": true }
    }
    

    When building, this with Angular 8.1.0, I'm getting anERROR in ENOTDIR: not a directory, scandir '{...}/client/src/config.dev.ts', which makes me think there's an assumption that the path mappings always map to a directory. Setting an exception breakpoint allowed me to get the stack trace:

    Error
        at handleErrorFromBinding (fs.js:126:5)
        at Object.readdirSync (fs.js:795:3)
        at NodeJSFileSystem.readdir (node_modules/@angular/compiler-cli/src/ngtsc/file_system/src/node_js_file_system.js:37:74)
        at EntryPointFinder.walkDirectoryForEntryPoints (node_modules/@angular/compiler-cli/ngcc/src/packages/entry_point_finder.js:85:18)
        at node_modules/@angular/compiler-cli/ngcc/src/packages/entry_point_finder.js:36:123
        at Array.reduce (<anonymous>)
        at EntryPointFinder.findEntryPoints (node_modules/@angular/compiler-cli/ngcc/src/packages/entry_point_finder.js:36:49)
        at Object.mainNgcc [as process] (node_modules/@angular/compiler-cli/ngcc/src/main.js:68:25)
        at NgccProcessor.processModule (node_modules/@ngtools/webpack/src/ngcc_processor.js:54:16)
        at node_modules/@ngtools/webpack/src/compiler_host.js:317:36
    

    Maybe the EntryPointFinder should check if the path mappings do in fact map to a directory or not.

  2. added this to the needsTriage milestone on Jul 5, 2019
  3. gkalpak commented on Jul 6, 2019

    @gkalpak
    Member

    I think you are right, @michael42. The changes in #30525 affect how pathMappings are used, but doesn't solve the problem in its current state (see https://github.com/angular/angular/pull/30525/files#r300829346).

  4. spock123 commented on Jul 8, 2019

    @spock123

    Getting same issue, for me it's the environment files that give IVY a headache..

  5. petebacondarwin commented on Jul 9, 2019

    @petebacondarwin
    Contributor

    This should be fixed as part of #30525

  6. julianobrasil commented on Jul 11, 2019

    @julianobrasil
    Author

    @petebacondarwin, in another project of mine, I use linqts. It gives me a message slightly different:

    
    ERROR in ENOENT: no such file or directory, lstat 'E:/Users/Juliano/Documents/Projetos/SA-R/sar-frontend/node_modules/linqts/index.ts'
    

    In fact, there's no index.ts on the folder mentioned on the error message. Is it a problem that I should post on linqts repo?

  7. petebacondarwin commented on Jul 11, 2019

    @petebacondarwin
    Contributor

    Yes this is a bug in the package.json for linqts. See https://unpkg.com/linqts@1.12.5/package.json

    {
      "name": "linqts",
      "version": "1.12.5",
      "description": "LinQ + TypeScript",
      "es2015": "index.ts",
      "source": "index.ts",
      ...
    

    The es2015 property should not point to the non-existing index.ts file.

    You can work around this by placing the following ngcc.config.js file at the root of your project:

    module.exports = {
      packages: {
        'linqts': {
          entryPoints: {
            '.': {
              override: { es2015: undefined }
            }
          }
        }
      }
    };
    

    This should tell ngcc to ignore this property in the package.json.

  8. julianobrasil commented on Jul 11, 2019

    @julianobrasil
    Author

    Great! I'll open an issue on that repo and continue with ivy testing.

  9. julianobrasil commented on Jul 11, 2019

    @julianobrasil
    Author

    Well, the compiler didn't like the undefined value:

    
    ERROR in The "path" argument must be of type string. Received type object
    

    Is there a way to force it to accept it?

    [UPDATE]: it accepted 'dist/index.js' instead of undefined

  10. petebacondarwin commented on Jul 12, 2019

    @petebacondarwin
    Contributor

    Interesting that it failed with the undefined... glad you got a workaround working.

  11. petebacondarwin commented on Jul 12, 2019

    @petebacondarwin
    Contributor

    Actually I just realised that linqts does not contain any Angular, does it? In which case we could just tell ngcc to ignore it:

    module.exports = {
      packages: {
        'linqts': {
          entryPoints: {
            '.': {
              ignore: true
            }
          }
        }
      }
    };
    

    That being said, it should already be ignored by ngcc as it has no ...metadata.json file, so I am not sure why it is erroring in the first place.

    I tried:

    mkdir temp
    cd temp
    yarn init
    yarn add linqts
    yarn add @angular/compiler
    yarn add @angular/compiler-cli
    yarn add typescript
    yarn ivy-ngcc -l debug
    

    which runs fine:

    Compiling @angular/compiler/testing : fesm2015 as esm2015
    Compiling @angular/compiler/testing : fesm5 as esm5
    Compiling @angular/compiler/testing : esm2015 as esm2015
    Compiling @angular/compiler/testing : esm5 as esm5
    Compiling @angular/compiler/testing : main as umd
    
  12. petebacondarwin commented on Jul 12, 2019

    @petebacondarwin
    Contributor

    Ahah! But running it targeted on the linqts does fail:

    yarn ivy-ngcc -l debug -t linqts
    

    leads to

    Error: ENOENT: no such file or directory, lstat '...temp/node_modules/linqts/index.ts'
        at Object.lstatSync (fs.js:840:3)
        at NodeJSFileSystem.lstat (...temp/node_modules/@angular/compiler-cli/src/ngtsc/file_system/src/node_js_file_system.js:38:72)
        at CachedFileSystem.lstat (...temp/node_modules/@angular/compiler-cli/src/ngtsc/file_system/src/cached_file_system.js:87:38)
        at CachedFileSystem.readFile (...temp/node_modules/@angular/compiler-cli/src/ngtsc/file_system/src/cached_file_system.js:35:30)
        at EsmDependencyHost.recursivelyFindDependencies (...temp/node_modules/@angular/compiler-cli/ngcc/src/dependencies/esm_dependency_host.js:59:40)
        at EsmDependencyHost.findDependencies (...temp/node_modules/@angular/compiler-cli/ngcc/src/dependencies/esm_dependency_host.js:41:18)
        at DependencyResolver.getEntryPointDependencies (...temp/node_modules/@angular/compiler-cli/ngcc/src/dependencies/dependency_resolver.js:66:25)
        at TargetedEntryPointFinder.processNextPath (...temp/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/targeted_entry_point_finder.js:57:42)
        at TargetedEntryPointFinder.findEntryPoints (...temp/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/targeted_entry_point_finder.js:46:22)
        at getTargetedEntryPoints (...temp/node_modules/@angular/compiler-cli/ngcc/src/main.js:141:37)
    

    which is what running via the CLI will do.

    This will be fixed by #31509

  13. julianobrasil commented on Jul 12, 2019

    @julianobrasil
    Author

    Good to know! After following you fixing that one, I found a dependency (ng2-file-upload), that became the next issue during compilation. It's maintained by valor-software. I'm reporting it to you here because it's kind of old (it uses @angular@2.x.x). Honestly, it seems to be abandoned (for this Ivy testing I've just replaced it by an updated version made available by another user of that library). My question is: should I report to you guys this kind of thing (very old angular-based dependencies) or save your time and just replace it in these projects (it's not healthy to keep abandoned projects as dependencies anyway).

  14. petebacondarwin commented on Jul 12, 2019

    @petebacondarwin
    Contributor
  15. angular-automatic-lock-bot commented on Sep 15, 2019

    @angular-automatic-lock-bot

    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.

  16. locked and limited conversation to collaborators on Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    regressionIndicates than the issue relates to something that worked in a previous versiontype: bug/fix

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions