nx icon indicating copy to clipboard operation
nx copied to clipboard

[@nwrl/js] TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received undefined

Open SkyaTura opened this issue 2 years ago β€’ 25 comments

Current Behavior

A specific package with one dependency always fail even the build from itself and the dependency are successful.

Expected Behavior

Don't fail and stop the run.

Github Repo

No response

Steps to Reproduce

  1. After realize my code was actually fine and completely built, I went verbose mode
  2. I found an error being thrown at /node_modules/@nrwl/js/src/utils/inline.js:171:48
  3. This line is the built version of this source code, which naively assume that result is always a valid key of inlinedDepsDestOutputRecord, and it's value is a string
        const importPath = `"${relative(
          dirPath,
          inlinedDepsDestOutputRecord[result]
        )}"`;
  1. I put a console.log, which it's output can be found below, and confirmed that result is actually undefined

I don't know how to reproduce it without exposing private code, I didn't found anything special different from any other file or package in this project that could explain such behavior.

Since I don't quite understand the core of this tool, so I can't explain it.

I'm sincerely sorry, but I've already lost many many hours trying to understand what was wrong with my code (that works and build perfectly fine outside nx workspace) to spend many more trying to figure how to reproduce it without changing the tool itself to test.

Nx Report

>  NX   Report complete - copy this into the issue template

   Node : 16.17.1
   OS   : darwin x64
   npm  : 8.19.2
   
   nx : 15.4.2
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.4.2
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.4.2
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.4.2
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.4.2
   @nrwl/js : 15.4.2
   @nrwl/linter : 15.4.2
   @nrwl/nest : 15.4.2
   @nrwl/next : Not Found
   @nrwl/node : 15.4.2
   @nrwl/nx-cloud : 15.0.2
   @nrwl/nx-plugin : 15.4.2
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.4.2
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : 15.4.2
   @nrwl/webpack : 15.4.2
   @nrwl/workspace : 15.4.2
   @nrwl/vite : Not Found
   typescript : 4.9.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
   	 @wanews/nx-esbuild: 0.26.1
   	 @wanews/nx-typescript-project-references: 0.21.0

Failure Logs

nx run utils:build

Compiling TypeScript files for project "utils"...
Done compiling TypeScript files for project "utils".
{
  dirPath: '[project_root_dir]/dist/packages/libs/utils/src',
  importRegex: /(?:)/g,
  inlinedDepsDestOutputRecord: {},
  filePath: '[project_root_dir]/dist/packages/libs/utils/src/address.d.ts',
  matched: '',
  result: '',
  value: undefined
}
node:internal/errors:477
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:387:5)
    at validateString (node:internal/validators:121:11)
    at relative (node:path:1192:5)
    at [project_root_dir]/node_modules/@nrwl/js/src/utils/inline.js:171:48
    at String.replace (<anonymous>)
    at recursiveUpdateImport ([project_root_dir]/node_modules/@nrwl/js/src/utils/inline.js:168:48)
    at recursiveUpdateImport ([project_root_dir]/node_modules/@nrwl/js/src/utils/inline.js:177:13)
    at updateImports ([project_root_dir]/node_modules/@nrwl/js/src/utils/inline.js:158:5)
    at postProcessInlinedDependencies ([project_root_dir]/node_modules/@nrwl/js/src/utils/inline.js:52:5)
    at [project_root_dir]/node_modules/@nrwl/js/src/executors/tsc/tsc.impl.js:87:57 {
  code: 'ERR_INVALID_ARG_TYPE'
}

Additional Information

No response

SkyaTura avatar Dec 31 '22 07:12 SkyaTura

@nartc, there is any test I can make to help solving this issue?

As I mentioned before, I don't have spare time to learn about nx's codebase, but I want to collaborate with the project.


If, by any chance, someone need an immediate workaround, it is nasty, but adding the following line on the mentioned file works for this version...

node_modules/@nrwl/js/src/utils/inline.js:170

if (!(result in inlinedDepsDestOutputRecord)) return result

I'm not quite sure if this have side effects, so, I would recommend against doing it on production environments...

SkyaTura avatar Jan 12 '23 17:01 SkyaTura

Hi @SkyaTura sorry for the late response, can you provide a simple reproduce?

nartc avatar Feb 22 '23 19:02 nartc

Hello @nartc, don't you worry. Better late than never hahaha

Hope we can work together on this.


Unfortunately, I couldn't reproduce on a fresh install, this only happens on my full project with many packages.

However, all packages was installed in the same way, following the documented steps of NX...

That said, I actually don't quite know what in world throws this exception. The only thing I was able to identify is that in the piece of code I mentioned above, result is expected to be a valid key of inlinedDepsDestOutputRecord, but this last one is an empty object, which causes resolve() to fail...

I've never had any problem with the workaround I applied manually on the last comment, tho.


Maybe, knowing what this section of the plugin is supposed to do, could you guide me to a test to provide more useful information for you?

SkyaTura avatar Feb 22 '23 20:02 SkyaTura

The inlinedDepsDestOutputRecord has the potential values:

{
   "@my-workspace/my-lib": "dist/libs/my-lib/src",
   "@my-workspace/my-lib-two": "dist/libs/my-lib-two/src",
   ...
}

In other words, inlinedDepsDestOutputRecord is a map between the path alias (tsconfig#paths) to the outputPath (in project.json) with hard-coded src (because that's where we generate the index.ts (aka entry point of a library)

The inline.ts code was trying to replace the import { someThing } from '@my-workspace/my-lib' to import { someThing } from '../relative/path/to/inlined-src/' if the library was inlined.

Maybe try to replicate your tsconfig.base.json as well in the reproduce? Just FYI, one of inline limitations at the moment is it does not support Deep Import. Eg: import { someDeepImport } from '@my-workspace/my-lib/some-deep/dir';

nartc avatar Feb 22 '23 20:02 nartc

Hmm πŸ€”

That clarifies a lot, one of my packages is a Nuxt@3 application, who basically works by doing some witchcraft on it's own tsconfig in order to generate auto-imports, although the error itself is being thrown on a dependency library that have nothing special at all.

I don't remember to deep import nothing from them, however, with that being said, maybe I can try to do some debugging to check if Nuxt isn't trying to optimize something on build to save bundle size by deep importing files directly.

SkyaTura avatar Feb 22 '23 20:02 SkyaTura

Also, I remember to see some tweaks somewhere to helps IDEs (such as VSCode and Volar Vue plugins) to correctly identify types and explicit auto-imports from external libraries.

I'll try to create a fresh reproduction with that specific settings asap and link here.

SkyaTura avatar Feb 22 '23 20:02 SkyaTura

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! πŸ™

github-actions[bot] avatar Mar 10 '23 00:03 github-actions[bot]

@nartc I've checked my project.

There is no Deep import happening. I've tried to get rid of all imports on the file I've detected the failure happening.

Actually, I even tried to compile with the whole file empty and the error persisted.

Error output:

> [email protected] build:api
> nx run api:build


 >  NX   workspace.json is ignored

   Nx no longer reads configuration from workspace.json.
   Run "nx g @nrwl/workspace:fix-configuration" to split workspace.json into individual project.json files.


   β ‹    Nx is waiting on 1 dependent project tasks before running tasks from api...

   βœ”    1/1 dependent project tasks succeeded [1 read from cache]
node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received an instance of RegExp
    at new NodeError (node:internal/errors:399:5)
    at validateString (node:internal/validators:163:11)
    at relative (node:path:1192:5)
    at /Users/skyatura/projects/gitlab/xxxx/xpto/xpto/node_modules/@nrwl/js/src/utils/inline.js:192:60
    at String.replace (<anonymous>)
    at recursiveUpdateImport (/Users/skyatura/projects/gitlab/xxxx/xpto/xpto/node_modules/@nrwl/js/src/utils/inline.js:177:48)
    at recursiveUpdateImport (/Users/skyatura/projects/gitlab/xxxx/xpto/xpto/node_modules/@nrwl/js/src/utils/inline.js:198:13)
    at updateImports (/Users/skyatura/projects/gitlab/xxxx/xpto/xpto/node_modules/@nrwl/js/src/utils/inline.js:167:5)
    at postProcessInlinedDependencies (/Users/skyatura/projects/gitlab/xxxx/xpto/xpto/node_modules/@nrwl/js/src/utils/inline.js:50:5)
    at /Users/skyatura/projects/gitlab/xxxx/xpto/xpto/node_modules/@nrwl/js/src/executors/tsc/tsc.impl.js:87:57 {

   βœ–    1/2 dependent project tasks failed (see below)
   βœ”    1/2 dependent project tasks succeeded [1 read from cache]

 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”


> nx run utils:build

Compiling TypeScript files for project "utils"...
Done compiling TypeScript files for project "utils".
{
  result: '',
  fileContent: "import { z } from 'zod';\n" +
    'declare enum BrazilStatesEnum {\n' +
    `    'Acre' = "AC",\n` +
    `    'Alagoas' = "AL",\n` +
    `    'AmapΓ‘' = "AP",\n` +
    `    'Amazonas' = "AM",\n` +
    `    'Bahia' = "BA",\n` +
    `    'CearΓ‘' = "CE",\n` +
    `    'Distrito Federal' = "DF",\n` +
    `    'EspΓ­rito Santo' = "ES",\n` +
    `    'GoiΓ‘s' = "GO",\n` +
    `    'MaranhΓ£o' = "MA",\n` +
    `    'Mato Grosso' = "MT",\n` +
    `    'Mato Grosso do Sul' = "MS",\n` +
    `    'Minas Gerais' = "MG",\n` +
    `    'ParΓ‘' = "PA",\n` +
    `    'ParaΓ­ba' = "PB",\n` +
    `    'ParanΓ‘' = "PR",\n` +
    `    'Pernambuco' = "PE",\n` +
    `    'PiauΓ­' = "PI",\n` +
    `    'Rio de Janeiro' = "RJ",\n` +
    `    'Rio Grande do Norte' = "RN",\n` +
    `    'Rio Grande do Sul' = "RS",\n` +
    `    'RondΓ΄nia' = "RO",\n` +
    `    'Roraima' = "RR",\n` +
    `    'Santa Catarina' = "SC",\n` +
    `    'SΓ£o Paulo' = "SP",\n` +
    `    'Sergipe' = "SE",\n` +
    `    'Tocantins' = "TO"\n` +
    '}\n' +
    'declare const SAddress: z.ZodObject<{\n' +
    '    zipCode: z.ZodString;\n' +
    '    street: z.ZodString;\n' +
    '    complement: z.ZodString;\n' +
    '    number: z.ZodString;\n' +
    '    neighborhood: z.ZodString;\n' +
    '    city: z.ZodString;\n' +
    '    country: z.ZodUnion<[z.ZodLiteral<"BR">, z.ZodString]>;\n' +
    '    state: z.ZodUnion<[z.ZodNativeEnum<typeof BrazilStatesEnum>, z.ZodString]>;\n' +
    '}, "strip", z.ZodTypeAny, {\n' +
    '    number: string;\n' +
    '    zipCode: string;\n' +
    '    street: string;\n' +
    '    complement: string;\n' +
    '    neighborhood: string;\n' +
    '    city: string;\n' +
    '    country: string;\n' +
    '    state: string;\n' +
    '}, {\n' +
    '    number: string;\n' +
    '    zipCode: string;\n' +
    '    street: string;\n' +
    '    complement: string;\n' +
    '    neighborhood: string;\n' +
    '    city: string;\n' +
    '    country: string;\n' +
    '    state: string;\n' +
    '}>;\n' +
    'type IAddress = z.infer<typeof SAddress>;\n' +
    "export type FormatAddressReturn<O> = O extends 'string' ? string : O extends 'array' ? string[] : Error;\n" +
    'export declare enum FormatAddressType {\n' +
    '    OneLine = "one-line",\n' +
    '    TwoLines = "two-lines",\n' +
    '    ThreeLines = "three-lines"\n' +
    '}\n' +
    "export type FormatAddressOutput = 'string' | 'array';\n" +
    "export type FormatStateOutput = 'short' | 'full' | 'as-is';\n" +
    'export interface FormatAddressOptions<O extends FormatAddressOutput> {\n' +
    '    format?: FormatAddressType;\n' +
    '    output?: O;\n' +
    '    outputState?: FormatStateOutput;\n' +
    '    pick?: (keyof IAddress)[];\n' +
    '    omit?: (keyof IAddress)[];\n' +
    '}\n' +
    'export interface FormatAddress {\n' +
    "    <O extends 'string'>(address: IAddress, options?: FormatAddressOptions<O>): string;\n" +
    "    <O extends 'array'>(address: IAddress, options?: FormatAddressOptions<O>): string[];\n" +
    '}\n' +
    'export declare const formatState: (state: string | null | undefined | BrazilStatesEnum | keyof BrazilStatesEnum, output?: FormatStateOutput, strict?: boolean) => any;\n' +
    'export declare const formatAddressThreeLines: <O extends FormatAddressOutput = "string">(address: IAddress, options?: FormatAddressOptions<O> | undefined) => FormatAddressReturn<O>;\n' +
    'export declare const formatAddressTwoLines: <O extends FormatAddressOutput = "string">(address: IAddress, options?: FormatAddressOptions<O> | undefined) => FormatAddressReturn<O>;\n' +
    'export declare const formatAddressOneLine: <O extends FormatAddressOutput = "string">(address: IAddress, options?: FormatAddressOptions<O> | undefined) => FormatAddressReturn<O>;\n' +
    'export declare const formatAddress: <O extends FormatAddressOutput = "string">(address: IAddress, options?: FormatAddressOptions<O> | undefined) => FormatAddressReturn<O>;\n' +
    'export declare const getAddressStatesList: () => {\n' +
    '    text: string;\n' +
    '    value: BrazilStatesEnum;\n' +
    '}[];\n' +
    'export {};\n',
  filePath: '/Users/skyatura/projects/gitlab/xxxx/xpto/xpto/dist/packages/libs/utils/src/address.d.ts',
  dirPath: '/Users/skyatura/projects/gitlab/xxxx/xpto/xpto/dist/packages/libs/utils/src',
  importRegex: /(?:)/g,
  inlinedDepsDestOutputRecord: {},
  rootParentDir: 'src'
}
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

 >  NX   Ran target build for project api and 2 task(s) they depend on (6s)
 
    βœ–    1/2 failed
    βœ”    1/2 succeeded [1 read from cache]

SkyaTura avatar Mar 13 '23 14:03 SkyaTura

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! πŸ™

github-actions[bot] avatar Mar 28 '23 00:03 github-actions[bot]

It is not stale, I still have the problem, but could get any additional information.

I'm waiting for instructions.

SkyaTura avatar Mar 28 '23 13:03 SkyaTura

I have the same problem. In my case it seems to be related to the mathJs package ...

m0e33 avatar Mar 29 '23 17:03 m0e33

I have the same problem, it fails for a library with no dependencies:

{
  importRegex: /(?:)/g,
  filePath: '/Users/itrulia/Documents/wepublish/dist/libs/website/api/src/index.d.ts',
  fileContent: "export * from './lib/graphql';\nexport * from './lib/client';\n",
  matched: '',
  result: '',
  inlinedDepsDestOutputRecord: {},
  rootParentDir: 'api'
}

If wanted I can point to a PR in our open source project if that would help. Wouldn't be a simple reproduction, but one nonetheless

image

dep graph shows dependencies are correct, but the inlinedDepsDestOutputRecord is empty for whatever reason

Itrulia avatar Apr 03 '23 12:04 Itrulia

@Itrulia did you found any workaround better than replacing compiled files to successfully build your project?

I really wish my project didn't have such a dirty requirement when installing dependencies.

SkyaTura avatar Apr 03 '23 17:04 SkyaTura

Unfortunately, even the simple if aboth won't fix my issue. As I want to re-export libraries in a publishable library, this bug causes that the import path is not replaced in the file itself as inlinedDepsDestOutputRecord is always an empty object.

With the aboth code change, atleast the libraries are moved to the correct position, but the import paths are not.

Itrulia avatar Apr 03 '23 18:04 Itrulia

@SkyaTura Okay so I found the issue that I was facing. All of my non publishable libraries were buildable (I made them buildable because of the eslint rule).

This caused

const shouldInline =
        /**
         * if all buildable libraries are marked as external,
         * then push the project dependency that doesn't have a build target
         */
        (options.external === 'all' && !buildOutputPath) ||
            /**
             * if all buildable libraries are marked as internal,
             * then push every project dependency to be inlined
             */
            options.external === 'none' ||
            /**
             * if some buildable libraries are marked as external,
             * then push the project dependency that IS NOT marked as external OR doesn't have a build target
             */
            (Array.isArray(options.external) &&
                options.external.length > 0 &&
                !options.external.includes(projectDependency.target)) ||
            !buildOutputPath;

to be false. If shouldInline is false, it does not set the inlinedDepsDestOutputRecord thus this always being empty. This might be the cause of your problem.

After I removed all the builds for the non publishable libraries. I faced a new issue: Error: ENOENT: no such file or directory, lstat '/Users/itrulia/Documents/wepublish/dist/libs/website/libs/website-api'. This error happens because of this line: movePackage(depOutputPath, destDepOutputPath);

When I console.log the variables, I got:

/Users/itrulia/Documents/wepublish/dist/libs/website libs/page/website
/Users/itrulia/Documents/wepublish/dist/libs/website libs/article/website
/Users/itrulia/Documents/wepublish/dist/libs/website libs/navigation/website
/Users/itrulia/Documents/wepublish/dist/libs/website libs/richtext/website
/Users/itrulia/Documents/wepublish/dist/libs/website libs/membership/website
/Users/itrulia/Documents/wepublish/dist/libs/website libs/block-content/website
/Users/itrulia/Documents/wepublish/dist/libs/website libs/authentication/website
/Users/itrulia/Documents/wepublish/dist/libs/website libs/website-builder
/Users/itrulia/Documents/wepublish/dist/libs/website libs/website-api
/Users/itrulia/Documents/wepublish/dist/libs/website libs/website-api-v2
/Users/itrulia/Documents/wepublish/dist/libs/website libs/website-api

/Users/itrulia/Documents/wepublish/dist/libs/website libs/website-api was in the output twice, the 2nd time this is logged, the build fails.

If I console.log Object.values(inlineGraph.dependencies), I am getting this:

[
  [
    'page-website',
    'article-website',
    'navigation-website',
    'richtext-website',
    'membership-website',
    'block-content-website',
    'authentication-website',
    'website-builder',
    'website-api',
    'website-api-v2'
  ],
  [ 'website-api', 'website-builder', 'block-content-website' ],
  [
    'website-api', 'website-api',
    'website-api', 'website-api',
    'website-api', 'website-api',
    'website-api', 'website-api',
    'website-api', 'website-api',
    'website-api', 'website-api'
  ],
  [
    'website-builder',
    'website-api',
    'richtext-website',
    'website-builder',
    'website-api',
    'richtext-website',
    'website-builder',
    'website-api',
    'richtext-website'
  ],
  [
    'website-builder',
    'website-builder',
    'website-builder',
    'website-builder'
  ],
  [ 'website-api', 'website-builder', 'block-content-website' ],
  [ 'website-api', 'website-builder' ],
  [ 'website-builder', 'website-api', 'authentication-website' ],
  [ 'website-api', 'website-api' ]
]

This is the cause.

re https://github.com/nrwl/nx/issues/16125

Itrulia avatar Apr 05 '23 14:04 Itrulia

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! πŸ™

github-actions[bot] avatar Apr 20 '23 00:04 github-actions[bot]

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! πŸ™

Again, this is not stale. The problem still remains with no official solution for it.

SkyaTura avatar Apr 20 '23 01:04 SkyaTura

I have the same problem when trying to use https://github.com/mozilla/webextension-polyfill in my project.

Compiling TypeScript files for project "common-lib-abc"...
Done compiling TypeScript files for project "common-lib-abc".

node:internal/errors:477
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:387:5)
    at validateString (node:internal/validators:121:11)
    at relative (node:path:1192:5)
    at .../node_modules/@nrwl/js/src/utils/inline.js:182:60
    at String.replace (<anonymous>)
    at recursiveUpdateImport (.../node_modules/@nrwl/js/src/utils/inline.js:177:48)
    at recursiveUpdateImport (.../datahawks/node_modules/@nrwl/js/src/utils/inline.js:188:13)
    at updateImports (.../node_modules/@nrwl/js/src/utils/inline.js:167:5)

And here's the report:

   Node : 16.17.0
   OS   : darwin x64
   yarn : 1.22.19
   
   nx : 15.5.2
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.6.2
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.7.1
   @nrwl/esbuild : 15.6.3
   @nrwl/eslint-plugin-nx : 15.5.2
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.6.3
   @nrwl/js : 15.6.3
   @nrwl/linter : 15.5.2
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 15.5.2
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : 15.7.1
   @nrwl/react : 15.6.2
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.7.1
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : 15.7.1
   @nrwl/webpack : 15.6.3
   @nrwl/workspace : 15.5.2
   @nrwl/vite : Not Found
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

~This probably has something todo with using commonjs library.~ I tried to reproduce it with a fresh repo and it does not have that problem.

envil avatar May 04 '23 21:05 envil

@nartc I was able to reproduce the error in this commit.

Too see the error, clone this repo and run:

npm install
nx run common-example:build

To summary, the error occurred when I tried to use tsyringe and set "external": "all" in the project.json of the common-example library.

envil avatar May 16 '23 23:05 envil

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! πŸ™

github-actions[bot] avatar May 31 '23 00:05 github-actions[bot]

Yet not stale

SkyaTura avatar May 31 '23 02:05 SkyaTura

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! πŸ™

github-actions[bot] avatar Jun 15 '23 00:06 github-actions[bot]

Yet not stale

True

envil avatar Jun 15 '23 07:06 envil

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! πŸ™

github-actions[bot] avatar Jun 30 '23 00:06 github-actions[bot]

Not stale, this started happening in 16.4.0 in my case.

scheatkode avatar Jun 30 '23 13:06 scheatkode

Happening here too especially when using "external": "none" in my js:tsc build executor

zackarydev avatar Jul 11 '23 14:07 zackarydev

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! πŸ™

github-actions[bot] avatar Jul 26 '23 00:07 github-actions[bot]

@nartc I was able to reproduce the error in this commit.

Too see the error, clone this repo and run:

npm install
nx run common-example:build

To summary, the error occurred when I tried to use tsyringe and set "external": "all" in the project.json of the common-example library.

@nartc In this comment, I've provided a MRE. Please remove the tag blocked: More info needed. Thank you.

envil avatar Jul 27 '23 12:07 envil

I have a minimal repository with the lastest version of Nx that reproduces the issue. All of the configuration was generated with NX generators.

devonhumes avatar Jul 27 '23 14:07 devonhumes

The command to use is npx nx build parent

devonhumes avatar Jul 27 '23 15:07 devonhumes