Issue with library resolution in next.config.js
Opened this issue · 0 comments
rishitshivesh commented
Current Behavior
Created a lib called @core/common. Created a script to fetch envs for nextjs. However, when the application runs it is unable to find the script by the module @core/common. It is unable to resolve the path. (Also, unable to convert the ts file and make it capable to runninig in next.config.js file)
Error -> Cannot resolve module @core/common [MODULE_ERROR)
Expected Behavior
Resolution should work and I should be able to load scripts.
GitHub Repo
No response
Steps to Reproduce
- Create a lib.
- Add a script (ts)
- Import it in next.config.js
Nx Report
NX Report complete - copy this into the issue template
Node : 20.17.0
OS : darwin-arm64
Native Target : aarch64-macos
yarn : 4.3.1
nx : 19.5.7
@nx/js : 19.5.7
@nx/jest : 19.5.7
@nx/linter : 19.5.7
@nx/eslint : 19.5.7
@nx/workspace : 19.5.7
@nx/devkit : 19.5.7
@nx/eslint-plugin : 19.5.7
@nx/next : 19.5.7
@nx/playwright : 19.5.7
@nx/react : 19.5.7
@nx/rollup : 19.5.7
@nrwl/tao : 19.5.7
@nx/web : 19.5.7
@nx/webpack : 19.5.7
typescript : 5.5.4
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/jest/plugin
@nx/rollup/plugin
@nx/playwright/plugin
@nx/next/plugin
---------------------------------------
⚠️ Unable to construct project graph.
Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
An error occurred while processing files for the @nx/next/plugin plugin.
- apps/claims/next.config.mjs: Code: ERR_MODULE_NOT_FOUND; The provided arguments length (2) does not match the required ones (3).
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
Error [ERR_INTERNAL_ASSERTION]: Code: ERR_MODULE_NOT_FOUND; The provided arguments length (2) does not match the required ones (3).
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at assert (node:internal/assert:14:11)
at getMessage (node:internal/errors:594:5)
at new NodeError (node:internal/errors:471:20)
at legacyMainResolve (node:internal/modules/esm/resolve:221:9)
at packageResolve (node:internal/modules/esm/resolve:848:14)
at moduleResolve (node:internal/modules/esm/resolve:934:18)
at defaultResolve (node:internal/modules/esm/resolve:1176:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
Failure Logs
node:internal/modules/esm/resolve:215
const resolvedOption = FSLegacyMainResolve(packageJsonUrlString, packageConfig.main, baseStringified);
^
Error: Cannot find package '/Users/rishitshivesh/Work/Vidal-fe/node_modules/@core/common/index.js' imported from /Users/rishitshivesh/Work/Vidal-fe/apps/claims/next.config.mjs
at legacyMainResolve (node:internal/modules/esm/resolve:215:26)
at packageResolve (node:internal/modules/esm/resolve:841:14)
at moduleResolve (node:internal/modules/esm/resolve:927:18)
at defaultResolve (node:internal/modules/esm/resolve:1169:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:540:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:509:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:96:40)
at link (node:internal/modules/esm/module_job:95:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v20.17.0
Package Manager Version
yarn@4.3.1
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
No response