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
Hi, I am trying to use module-alias in my project and I am using node js 15.x type: module in package.json but it not working for me. see below code snippets.
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@con/module' imported from D:\projects\Node\alias-test\server.js
?[90m at new NodeError (node:internal/errors:278:15)?[39m
?[90m at packageResolve (node:internal/modules/esm/resolve:698:9)?[39m
?[90m at moduleResolve (node:internal/modules/esm/resolve:739:18)?[39m
?[90m at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:853:11)?[39m
?[90m at Loader.resolve (node:internal/modules/esm/loader:86:40)?[39m
?[90m at Loader.getModuleJob (node:internal/modules/esm/loader:230:28)?[39m
?[90m at ModuleWrap. (node:internal/modules/esm/module_job:56:40)?[39m
?[90m at link (node:internal/modules/esm/module_job:55:36)?[39m {
code: ?[32m'ERR_MODULE_NOT_FOUND'?[39m
The text was updated successfully, but these errors were encountered:
Hi, I am trying to use module-alias in my project and I am using node js 15.x type: module in package.json but it not working for me. see below code snippets.
package.json
{
"name": "alias-test",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"module-alias": "^2.2.2"
},
"type": "module",
"_moduleAliases" : {
"@root" : ".",
"@con" : "./config"
}
}
server.js
require('module-alias/register');
import '@con/module';
module.js
console.log("from Module Config");
getting error :
node:internal/process/esm_loader:74
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@con/module' imported from D:\projects\Node\alias-test\server.js
?[90m at new NodeError (node:internal/errors:278:15)?[39m
?[90m at packageResolve (node:internal/modules/esm/resolve:698:9)?[39m
?[90m at moduleResolve (node:internal/modules/esm/resolve:739:18)?[39m
?[90m at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:853:11)?[39m
?[90m at Loader.resolve (node:internal/modules/esm/loader:86:40)?[39m
?[90m at Loader.getModuleJob (node:internal/modules/esm/loader:230:28)?[39m
?[90m at ModuleWrap. (node:internal/modules/esm/module_job:56:40)?[39m
?[90m at link (node:internal/modules/esm/module_job:55:36)?[39m {
code: ?[32m'ERR_MODULE_NOT_FOUND'?[39m
The text was updated successfully, but these errors were encountered: