Mocha cannot resolve absolute path from node_modules
i'm working on frontend project, inside i have some private packages, and all the private packages are included as dependencies inside the parent package, and i tried to run the project it will work as expected, but when i tried to run unit test on parent project, mocha will fail and will throw an error that it cannot resolve imports from private package.
Start testing for: /.main.spec.js?/
module.js:549
throw err;
^
Error: Cannot find module 'pckgA/user/model'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (D:workspace1Parentnode_modules@comppckgBlibformcontainer.js:13:14)
at Module._compile (module.js:652:30)
at Module._extensions..js (module.js:663:10)
at Object.require.extensions.(anonymous function) [as .js] (D:workspace1properanode_modulesbabel-registerlibnode.js:152:7)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
here's my configs:
webpack resolve
resolve: {
modules: ['./app', 'node_modules'],
babelrc
{
"presets": [
"react",
"env"
],
"plugins": [
"syntax-dynamic-import",
"transform-es2015-destructuring",
"transform-object-rest-spread",
[
"babel-plugin-transform-builtin-extend",
{
"globals": [
"Error"
]
}
]
],
"env": {
"coverageTesting": {
"plugins": [
"istanbul"
]
},
"development": {
"presets": [
"react-hmre"
]
},
"renderCheck": {
"presets": [
"react-hmre"
],
"plugins": [
[
"react-transform",
{
"transforms": [
{
"transform": "react-transform-render-visualizer"
}
]
}
]
]
},
"testing": {
"plugins": [
"syntax-dynamic-import",
"dynamic-import-node",
[
"module-resolver", {
"alias": {
"public": "./public/"
}
}
]
]
}
}
}
webpack dependencies mocha
add a comment |
i'm working on frontend project, inside i have some private packages, and all the private packages are included as dependencies inside the parent package, and i tried to run the project it will work as expected, but when i tried to run unit test on parent project, mocha will fail and will throw an error that it cannot resolve imports from private package.
Start testing for: /.main.spec.js?/
module.js:549
throw err;
^
Error: Cannot find module 'pckgA/user/model'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (D:workspace1Parentnode_modules@comppckgBlibformcontainer.js:13:14)
at Module._compile (module.js:652:30)
at Module._extensions..js (module.js:663:10)
at Object.require.extensions.(anonymous function) [as .js] (D:workspace1properanode_modulesbabel-registerlibnode.js:152:7)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
here's my configs:
webpack resolve
resolve: {
modules: ['./app', 'node_modules'],
babelrc
{
"presets": [
"react",
"env"
],
"plugins": [
"syntax-dynamic-import",
"transform-es2015-destructuring",
"transform-object-rest-spread",
[
"babel-plugin-transform-builtin-extend",
{
"globals": [
"Error"
]
}
]
],
"env": {
"coverageTesting": {
"plugins": [
"istanbul"
]
},
"development": {
"presets": [
"react-hmre"
]
},
"renderCheck": {
"presets": [
"react-hmre"
],
"plugins": [
[
"react-transform",
{
"transforms": [
{
"transform": "react-transform-render-visualizer"
}
]
}
]
]
},
"testing": {
"plugins": [
"syntax-dynamic-import",
"dynamic-import-node",
[
"module-resolver", {
"alias": {
"public": "./public/"
}
}
]
]
}
}
}
webpack dependencies mocha
add a comment |
i'm working on frontend project, inside i have some private packages, and all the private packages are included as dependencies inside the parent package, and i tried to run the project it will work as expected, but when i tried to run unit test on parent project, mocha will fail and will throw an error that it cannot resolve imports from private package.
Start testing for: /.main.spec.js?/
module.js:549
throw err;
^
Error: Cannot find module 'pckgA/user/model'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (D:workspace1Parentnode_modules@comppckgBlibformcontainer.js:13:14)
at Module._compile (module.js:652:30)
at Module._extensions..js (module.js:663:10)
at Object.require.extensions.(anonymous function) [as .js] (D:workspace1properanode_modulesbabel-registerlibnode.js:152:7)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
here's my configs:
webpack resolve
resolve: {
modules: ['./app', 'node_modules'],
babelrc
{
"presets": [
"react",
"env"
],
"plugins": [
"syntax-dynamic-import",
"transform-es2015-destructuring",
"transform-object-rest-spread",
[
"babel-plugin-transform-builtin-extend",
{
"globals": [
"Error"
]
}
]
],
"env": {
"coverageTesting": {
"plugins": [
"istanbul"
]
},
"development": {
"presets": [
"react-hmre"
]
},
"renderCheck": {
"presets": [
"react-hmre"
],
"plugins": [
[
"react-transform",
{
"transforms": [
{
"transform": "react-transform-render-visualizer"
}
]
}
]
]
},
"testing": {
"plugins": [
"syntax-dynamic-import",
"dynamic-import-node",
[
"module-resolver", {
"alias": {
"public": "./public/"
}
}
]
]
}
}
}
webpack dependencies mocha
i'm working on frontend project, inside i have some private packages, and all the private packages are included as dependencies inside the parent package, and i tried to run the project it will work as expected, but when i tried to run unit test on parent project, mocha will fail and will throw an error that it cannot resolve imports from private package.
Start testing for: /.main.spec.js?/
module.js:549
throw err;
^
Error: Cannot find module 'pckgA/user/model'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (D:workspace1Parentnode_modules@comppckgBlibformcontainer.js:13:14)
at Module._compile (module.js:652:30)
at Module._extensions..js (module.js:663:10)
at Object.require.extensions.(anonymous function) [as .js] (D:workspace1properanode_modulesbabel-registerlibnode.js:152:7)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
here's my configs:
webpack resolve
resolve: {
modules: ['./app', 'node_modules'],
babelrc
{
"presets": [
"react",
"env"
],
"plugins": [
"syntax-dynamic-import",
"transform-es2015-destructuring",
"transform-object-rest-spread",
[
"babel-plugin-transform-builtin-extend",
{
"globals": [
"Error"
]
}
]
],
"env": {
"coverageTesting": {
"plugins": [
"istanbul"
]
},
"development": {
"presets": [
"react-hmre"
]
},
"renderCheck": {
"presets": [
"react-hmre"
],
"plugins": [
[
"react-transform",
{
"transforms": [
{
"transform": "react-transform-render-visualizer"
}
]
}
]
]
},
"testing": {
"plugins": [
"syntax-dynamic-import",
"dynamic-import-node",
[
"module-resolver", {
"alias": {
"public": "./public/"
}
}
]
]
}
}
}
webpack dependencies mocha
webpack dependencies mocha
asked Nov 21 at 9:20
M1M6
1752318
1752318
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408764%2fmocha-cannot-resolve-absolute-path-from-node-modules%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408764%2fmocha-cannot-resolve-absolute-path-from-node-modules%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown