Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: spawnSync C:\Users\me\repo\oas-web\node_modules\ts-node\dist\bin.js UNKNOWN #1867

Closed
JonWallsten opened this issue Feb 10, 2021 · 13 comments · Fixed by #1876
Closed

Comments

@JonWallsten
Copy link

JonWallsten commented Feb 10, 2021

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

After upgradring from 11.1.2 -> 11.2.0 I'm no longer able to build our project. Compilation fails with the error message below:

------------------------------------------------------------------------------
Building entry point '@oas/web-lib-angular' 
------------------------------------------------------------------------------
✖ Compiling TypeScript sources through NGC 
ERROR: spawnSync C:\Users\me\repo\oas-web\node_modules\ts-node\dist\bin.js UNKNOWN
<ref *1> Error: spawnSync C:\Users\me\repo\oas-web\node_modules\ts-node\dist\bin.js UNKNOWN 
    at Object.spawnSync (internal/child_process.js:1067:20)
    at spawnSync (child_process.js:602:24)
    at Object.execFileSync (child_process.js:629:15)
    at StylesheetProcessor.process (C:\Users\me\repo\oas-web\packages\web-lib-angular\node_modules\src\lib\styles\stylesheet-processor.ts:40:20)
    at Object.readResource (C:\Users\me\repo\oas-web\packages\web-lib-angular\node_modules\src\lib\ts\cache-compiler-host.ts:136:47)
    at AdapterResourceLoader.preload (C:\Users\me\packages\compiler-cli\src\ngtsc\resource\src\loader.ts:80:33)
    at resolveStyleUrl (C:\Users\me\packages\compiler-cli\src\ngtsc\annotations\src\component.ts:163:43)
    at Array.map (<anonymous>)
    at ComponentDecoratorHandler.preanalyze (C:\Users\me\packages\compiler-cli\src\ngtsc\annotations\src\component.ts:186:75)
    at _loop_1 (C:\Users\me\packages\compiler-cli\src\ngtsc\transform\src\compilation.ts:312:39) {
  errno: -4094,
  code: 'UNKNOWN',
  syscall: 'spawnSync C:\\Users\\me\\repo\\oas-web\\node_modules\\ts-node\\dist\\bin.js',
  path: 'C:\\Users\\me\\repo\\oas-web\\node_modules\\ts-node\\dist\\bin.js',
  spawnargs: [
    'C:\\Users\\me\\repo\\oas-web\\packages\\web-lib-angular\\node_modules\\ng-packagr\\lib\\styles\\stylesheet-processor-worker.js',
    '{"filePath":"C:\\\\Users\\\\me\\\\repo\\\\oas-web\\\\packages\\\\web-lib-angular\\\\src\\\\components\\\\action-menu\\\\action-menu.component.scss","basePath":"C:\\\\Users\\\\me\\\\repo\\\\oas-web\\\\packages\\\\web-lib-angular","cssUrl":"inline","styleIncludePaths":[],"browserslistData":["and_chr 88","and_ff 83","and_qq 10.4","and_uc 12.12","android 81","baidu 7.12","chrome 88","chrome 87","chrome 86","edge 88","edge 87","firefox 85","firefox 84","firefox 78","ie 11","ios_saf 14.0-14.4","ios_saf 13.4-13.7","ios_saf 12.2-12.4","kaios 2.5","op_mini all","op_mob 59","opera 72","opera 71","safari 14","safari 13.1","samsung 13.0","samsung 12.0"]}'
  ],
  error: [Circular *1],
  status: null,
  signal: null,
  output: null,
  pid: 0,
  stdout: null,
  stderr: null
}

How To Reproduce

Not sure since I'm not sure what's wrong. I tried to debug with DevTools for Node.JS, but the build actually succeeded when I stepped through all the caught/uncaught exceptions. So there might be a race condition somewhere.
I can't publish our full repo since the code is not open source. But we have a pretty simple lib with some components and directives.
I'm using ts-node to inittiate ng-packagr:
cross-env NODE_ENV=development ts-node ng-packagr

//ng-packagr.ts
ngPackage
        .ngPackagr()
        .forProject('ng-package.json')
        .withTsConfig('tsconfig.build.json')
        .build()
        .catch(error => {
            console.error(error);
            process.exit(1);
        });

Expected Behaviour

The building process should finish without error.

Version Information

ng-packagr:            11.2.0 
@angular/compiler:     11.1.2 
rollup:                2.38.5
tsickle:
typescript:            4.1.4
@SchnWalter
Copy link
Contributor

Are you using npm link or yarn link to install a local version of @angular/compiler-cli?

You should not see TypeScript files in your error, like: C:\Users\me\packages\compiler-cli\src\ngtsc\annotations\src\component.ts.

@JonWallsten
Copy link
Author

Not deliberately at least. Can double check tomorrow, but I highly doubt it. We don't use any synlinks in our monorepo.

@JonWallsten
Copy link
Author

Maybe some issue with ngcc/ivy. I'll reinstall everything tomorrow.

@flash-me
Copy link

Not deliberately at least. Can double check tomorrow, but I highly doubt it. We don't use any synlinks in our monorepo.

🤔 Sure there is no linking?

C:\Users\me\repo\oas-web\node_modules\....
Your workspace is at ^^^^^

But

C:\Users\me\packages\compiler-cli\...
Errors point to ^^^^^

🤷🏽‍♂️
Implicitly it's also a link If dependencies are referring to relative / absolve paths, e. g. when the cloned git repo is being used instead of a released package.

cheers
flash ⚡

@JonWallsten
Copy link
Author

JonWallsten commented Feb 11, 2021

C:\Users\me\packages\compiler-cli\ doesn't exist. I don't have any symlinks. If that path is shown, there's probably a bug somewhere in the resolver.

We do however use a monorepo.
So my angular packages are located in C:\Users\me\repo\oas-web\node_modules and ng-packagr is located in C:\Users\me\repo\oas-web\packages\web-lib-angular\node_modules.

@flash-me
Copy link

Uhm alright, but how does it come that you have typescript files?
If ng-packagr is located in a node_modules directory, I assume its installed as a dependency and therefore may consist of .js and .d.ts files.
Given that, you wouldn't have to use ts-node at all?

cheers
flash ⚡

@JonWallsten
Copy link
Author

I don't have any TypeScript files in C:\Users\me\repo\oas-web\node_modules\@angular\compiler-cli. Not sure why the output shows it tries to resolve those. These paths/files does not exist.
I use ts-node because I want typings in my ng-packagr.ts. But yes, I could use node and make it a js-file instead. That would however just cover up this issue.

@flash-me
Copy link

flash-me commented Feb 11, 2021

Not it wouldn't. These are runtime errors, ts-node would give you compile time reports. Anyway.

The issues are related to action-menu.component.scss, can you check if the component etc are valid? Are there circular Imports? (both scss and ts)

cheers
flash ⚡

@JonWallsten
Copy link
Author

It builds perfectly fine when downgrading. But I will resinstall all the modules. This might be a non-issue.

@SchnWalter
Copy link
Contributor

SchnWalter commented Feb 11, 2021

What happens if you change your extension to .js and run using node?

You mentioned downgrading, what version did you use before?

@JonWallsten
Copy link
Author

JonWallsten commented Feb 12, 2021

After clearing node_modules for our entire monorepo and then reinstalling everything, including upgrading the rest of the angular components to 11.2.0 i get the same thing.

✖ Compiling TypeScript sources through NGC
ERROR: spawnSync C:\Users\me\repo\oas-web\node_modules\ts-node\dist\bin.js UNKNOWN
<ref *1> Error: spawnSync C:\Users\me\repo\oas-web\node_modules\ts-node\dist\bin.js UNKNOWN
    at Object.spawnSync (internal/child_process.js:1067:20)
    at spawnSync (child_process.js:602:24)
    at Object.execFileSync (child_process.js:629:15)
    at StylesheetProcessor.process (C:\Users\me\repo\oas-web\packages\web-lib-angular\node_modules\src\lib\styles\stylesheet-processor.ts:40:20)
    at Object.readResource (C:\Users\me\repo\oas-web\packages\web-lib-angular\node_modules\src\lib\ts\cache-compiler-host.ts:136:47)
    at AdapterResourceLoader.preload (C:\Users\me\packages\compiler-cli\src\ngtsc\resource\src\loader.ts:80:33)
    at resolveStyleUrl (C:\Users\me\packages\compiler-cli\src\ngtsc\annotations\src\component.ts:190:38)
    at C:\Users\me\packages\compiler-cli\src\ngtsc\annotations\src\component.ts:223:29
    at Array.map (<anonymous>)
    at ComponentDecoratorHandler.preanalyze (C:\Users\me\packages\compiler-cli\src\ngtsc\annotations\src\component.ts:222:35) {
  errno: -4094,
  code: 'UNKNOWN',
  syscall: 'spawnSync C:\\Users\\me\\repo\\oas-web\\node_modules\\ts-node\\dist\\bin.js',
  path: 'C:\\Users\\me\\repo\\oas-web\\node_modules\\ts-node\\dist\\bin.js',
  spawnargs: [
    'C:\\Users\\me\\repo\\oas-web\\packages\\web-lib-angular\\node_modules\\ng-packagr\\lib\\styles\\stylesheet-processor-worker.js',
    '{"filePath":"C:\\\\Users\\\\me\\\\repo\\\\oas-web\\\\packages\\\\web-lib-angular\\\\src\\\\components\\\\action-menu\\\\action-menu.component.scss","basePath":"C:\\\\Users\\\\me\\\\repo\\\\oas-web\\\\packages\\\\web-lib-angular","cssUrl":"inline","styleIncludePaths":[],"browserslistData":["and_chr 88","and_ff 83","and_qq 10.4","and_uc 12.12","android 81","baidu 7.12","chrome 88","chrome 87","chrome 86","edge 88","edge 87","firefox 85","firefox 84","firefox 78","ie 11","ios_saf 14.0-14.4","ios_saf 13.4-13.7","ios_saf 12.2-12.4","kaios 2.5","op_mini all","op_mob 59","opera 72","opera 71","safari 14","safari 13.1","samsung 13.0","samsung 12.0"]}'
  ],
  error: [Circular *1],
  status: null,
  signal: null,
  output: null,
  pid: 0,
  stdout: null,
  stderr:

It works perfectly fine with 11.1.2. So they definitely broke something in the release.
Running without ts-node works fine, but I'm using local build tools written in TypeScript, so it would be a hassle to pre-compile those compared to just running ts-node.

I will check if you can run ts-node without sourcemaps so we can get the real paths.

@JonWallsten
Copy link
Author

@alan-agius4 Just wanted to confirm that it works! Thanks!

@github-actions
Copy link

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

This action has been performed automatically by a bot.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants