You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to build a nextjs app and using typescript config files. If I import another typescript file (in my case a common next config from libs) I'm getting the following error
Cannot find file "../../libs/next-configs/src/lib/next-configs" with any of the following extensions: .js, .cjs, .mjs, .json
Error: Cannot find file "../../libs/next-configs/src/lib/next-configs" with any of the following extensions: .js, .cjs, .mjs, .json
at /Users/PROJECT/node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js:167:19
at Array.map (<anonymous>)
at ensureFileExtensions (/Users/PROJECT/node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js:158:18)
at doCollect (/Users/PROJECT/node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js:121:25)
at getRelativeFilesToCopy (/Users/PROJECT/node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js:129:5)
at createNextConfigFile (/Users/PROJECT/node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js:46:31)
at buildExecutor (/Users/PROJECT/node_modules/@nx/next/src/executors/build/build.impl.js:78:60)
at async promiseToIterator (/Users/PROJECT/node_modules/nx/src/command-line/run/run.js:36:11)
at async getLastValueFromAsyncIterableIterator (/Users/PROJECT/node_modules/nx/src/utils/async-iterator.js:15:19)
at async iteratorToProcessStatusCode (/Users/PROJECT/node_modules/nx/src/command-line/run/run.js:39:25)
Failing in my next.config.ts file here
import { nextSecurityConfigs } from '../../libs/next-configs/src/lib/next-configs';
If I go into node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js on line 157 I see const extensions = ['.js', '.cjs', '.mjs', '.json']; Adding ts to this array fixes the issue
On a separate note I had to import it like that because doing import { nextSecurityConfigs } from '@PROJECT/next-configs gave me a module not found error during the serve and build targets
Expected Behavior
I should be able to use typescript import files in typescript files
GitHub Repo
No response
Steps to Reproduce
Create a new NextJs application
Create a new lib with next configs
Add a typescript file to the new lib
Attempt to import the file in your next.config.ts file in your next application
Cannot find file "../../libs/next-configs/src/lib/next-configs" with any of the following extensions: .js, .cjs, .mjs, .json
Error: Cannot find file "../../libs/next-configs/src/lib/next-configs" with any of the following extensions: .js, .cjs, .mjs, .json
at /Users/PROJECT/node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js:167:19
at Array.map (<anonymous>)
at ensureFileExtensions (/Users/PROJECT/node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js:158:18)
at doCollect (/Users/PROJECT/node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js:121:25)
at getRelativeFilesToCopy (/Users/PROJECT/node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js:129:5)
at createNextConfigFile (/Users/PROJECT/node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js:46:31)
at buildExecutor (/Users/PROJECT/node_modules/@nx/next/src/executors/build/build.impl.js:78:60)
at async promiseToIterator (/Users/PROJECT/node_modules/nx/src/command-line/run/run.js:36:11)
at async getLastValueFromAsyncIterableIterator (/Users/PROJECT/node_modules/nx/src/utils/async-iterator.js:15:19)
at async iteratorToProcessStatusCode (/Users/PROJECT/node_modules/nx/src/command-line/run/run.js:39:25)
Package Manager Version
Yarn 4.2.2
Operating System
macOS
Linux
Windows
Other (Please specify)
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Current Behavior
When attempting to build a nextjs app and using typescript config files. If I import another typescript file (in my case a common next config from libs) I'm getting the following error
Failing in my
next.config.ts
file hereIf I go into
node_modules/@nx/next/src/executors/build/lib/create-next-config-file.js
on line 157 I seeconst extensions = ['.js', '.cjs', '.mjs', '.json'];
Addingts
to this array fixes the issueOn a separate note I had to import it like that because doing
import { nextSecurityConfigs } from '@PROJECT/next-configs
gave me a module not found error during the serve and build targetsExpected Behavior
I should be able to use typescript import files in typescript files
GitHub Repo
No response
Steps to Reproduce
Nx Report
Failure Logs
Package Manager Version
Yarn 4.2.2
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: