-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[@nwrl/js] TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received undefined #14071
Comments
@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... |
Hi @SkyaTura sorry for the late response, can you provide a simple reproduce? |
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, 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? |
The {
"@my-workspace/my-lib": "dist/libs/my-lib/src",
"@my-workspace/my-lib-two": "dist/libs/my-lib-two/src",
...
} In other words, The Maybe try to replicate your |
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. |
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. |
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. |
@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:
{
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'
}
|
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. |
It is not stale, I still have the problem, but could get any additional information. I'm waiting for instructions. |
I have the same problem. In my case it seems to be related to the mathJs package ... |
I have the same problem, it fails for a library with no dependencies:
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 dep graph shows dependencies are correct, but the inlinedDepsDestOutputRecord is empty for whatever reason |
@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. |
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 With the aboth code change, atleast the libraries are moved to the correct position, but the import paths are not. |
@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
to be false. If After I removed all the builds for the non publishable libraries. I faced a new issue: When I console.log the variables, I got:
If I console.log
This is the cause. re #16125 |
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. |
Again, this is not stale. The problem still remains with no official solution for it. |
I have the same problem when trying to use https://github.com/mozilla/webextension-polyfill in my project.
And here's the report:
|
@nartc I was able to reproduce the error in this commit. Too see the error, clone this repo and run:
To summary, the error occurred when I tried to use tsyringe and set |
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. |
Yet not stale |
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. |
True |
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. |
Not stale, this started happening in |
Happening here too especially when using |
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. |
@nartc In this comment, I've provided a MRE. Please remove the tag |
I have a minimal repository with the lastest version of Nx that reproduces the issue. All of the configuration was generated with NX generators. |
The command to use is |
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. |
Yes, you missed it @github-actions |
@nartc will this ever be analyzed? |
You have to open a new issue now (or hope someone re-opens it) as you haven't answered to the bot in time. |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
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
/node_modules/@nrwl/js/src/utils/inline.js:171:48
inlinedDepsDestOutputRecord
, and it's value is a stringconsole.log
, which it's output can be found below, and confirmed thatresult
is actuallyundefined
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
Failure Logs
Additional Information
No response
The text was updated successfully, but these errors were encountered: