I have the Error: Cannot find module xyz/abcd error.
YES, the required module is installed.
According to the pseudo-code of module.require here, it should work.
I tried to dive inside require() to understand why it can't find my file. My node debugger won't step into require(). I've tried the strace / grep NOENT technique whithout success either.
Any idea how to troubleshoot a nasty require() failure ?
Note : just in case : the error comes from a file node_modules/xyz/a requiring xyz/b. It should work according to the doc.
By investigating more, I think I found a good technique :
export NODE_DEBUG=module
node my_script.js
gives such interesting traces :
looking for "/(...)/tests_init.js" in ["/home/(me)/.nave/installed/0.10.24/lib/node","/home/(me)/.node_modules","/home/(me)/.node_libraries","/home/(me)/.nave/installed/0.10.24/lib/node"]
And BTW, it shows that node is not searching at all where I thought it was. Time to investigate...
[edit] end of the story :
1) it appears that node is not treating well modules installed with npm link. require(...) sometimes fails to select files from inside a npm-linked module. I have no desire to investigate further the exact error conditions, I'll just conclude that npm link is very brittle.
2) beware of node looking for node_modules all the way into the parent dirs of current working directory ! I found that modules from parent folders of my app where sometime selected !
Related
I have a project in Angular 13. I want to use quillJS and I want to add tables so I tried to install quill-better-table in my project.
For some reason the package is not working. I used the web inspector and found this to be the issue:
ERROR TypeError: quill.keyboard.bindings.Backspace is undefined
The problem seems to be located at: quill_better_table_BetterTable quill-better-table.js:2979 and when I check the debugger I can see the line:
let thisBinding = quill.keyboard.bindings['Backspace'].pop();
quill.keyboard.bindings['Backspace'].splice(0, 1, thisBinding); // add Matchers to match and render quill-better-table for initialization
// or pasting
I found a github repo that had this issue fixed:
https://github.com/LosEcher/quill-better-table
The problem I'm running into is I dont know how to get that particular repo into my project. I have tried updating the current package and webpack continues to load the old one. I've tried clearing the npm cache and reinstalling the node packages.
I found this guide: https://whatapalaver.co.uk/npm-dependency which seems to indicate what I should do but I'm not quite npm literate enough to figure it out. Specifically, I dont know that I understand how to create the NPM link.
I'm looking for advice as to how to fix this package. I am going to be reading up on NPM link but I figured if there was another easier way to get this fixed then I would ask. I can load that repo into my node module folder, but I dont know how to make webpack reload the updated module.
Thanks in advance for the help, let me know what details I for got to add.
I've been at this for hours, and I've tried endless things and reinstalled NodeJS so, so many times.
I'm on Win10. I cannot run npm, it seems to have some PATH error I cannot get around this:
Error: Cannot find module 'C:\Program
Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
This path looks screwy, I know. I've removed any roaming entries in the PATH var for nodejs or npm. Only
C:\Program Files\nodejs
remains at this point.
Is there any real solution that works for Win10 every time?
I'll do anything at this point. I've tried so, so many things that I found here or a dozen other sites.
I'm not trying to do anything special. I just want to run npm at the command line successfully--update itself, check itself, anything. No matter how it's invoked, I get the error above.
I mean, what should the PATH look like? How can I make this thing happy?
Thanks for any help.
Had my node working with the VS Code debugger last night no problem. I haven't touched anything besides install the npm mysql package.
I come back tonight and its throwing this error:
Debugger listening on [::]:49952
dyld: lazy symbol binding failed: Symbol not found: _napi_module_register
Referenced from: /Users/adamsawyers/node_modules/bufferutil/prebuilds/darwin-
x64/node-napi.node
Expected in: flat namespace
dyld: Symbol not found: _napi_module_register
Referenced from: /Users/myusername/node_modules/bufferutil/prebuilds/darwin-
x64/node-napi.node
Expected in: flat namespace
Apparently my installation of n (a node version handling package in npm) is busted somehow. My research told me that napi_module_register is part of the n package, but I'm not sure how this got messed up especially since I had it working last night.
I tried reinstalling my node packages, reinstalling n, rebuilding the project file structure, even restarting my computer. Nothing has worked so far.
Any suggestions?
Apparently VS code doesn't like v6.10.3 of nodejs which I am running to create lambda functions in AWS (that is the version specified by AWS)
I use the N package to manage my node version. After switching to the latest version 10.7.0 as of 07/25/2018 (command: sudo n latest) and rerunning the debugger in VS code, it worked perfectly
I'm still unsure as the the cause, but hopefully others find this solution helpful
This exact error happened to me because:
I needed socket.io to run on Node
Which in turn needs ws (websockets on Node)
Also, I needed to run this on an outdated Node version (Node 7) for a very good reason (believe me, I would not want to do this if I wouldn't have to)
However, trying to use it on that old version causes above error message.
Solution
This is a terrible solution, but at least I got it to work.
After some researching, I found no good solution to this. However, a close look at the source code shows that there is a fallback.js next to index.js which implements the same functionality as the native build but without needing a build. This will probably slow things down significantly, but at least it works:
yarn add module-alias
prefix your actual code with this (e.g. via node -r fallbacks.js):
// fallbacks.js
const moduleAlias = require('module-alias');
const dependencyRoot = getDependencyRoot(); // whatever is your root folder, maybe __dirname + '..'
moduleAlias.addAlias('bufferutil', dependencyRoot + '/node_modules/bufferutil/fallback.js');
moduleAlias.addAlias('utf-8-validate', dependencyRoot + '/node_modules/utf-8-validate/fallback.js');
// run actual code here...
PS: In my case, in order to allow ws to run on Node 7, I also had to babel it, since its using modern synytax.
I have the following based on instructions from here:
const Pubgapi = require('pubg-api');
const apiInstance = new Pubgapi('api-key');
For some reason when I run it, the console says unable to resolve path but it's looking for a node-modules which I don't have. This is an API wrapper that I am trying to use by the way. What could cause it to give me this error?
I did an npm install as the instructions said and nothing else before the statements above.
Error message:
Unable to resolve ../node-modules/pubg-api" from ".//components/Main.js`: The module `../node-modules/pubg-api` could not be found"
I have checked the node_modules folder. It is indeed pubg-api, not pubg_api. Requiring pubg_api gives me this error.
This error is probably related to the HTTPS library that the library you are trying to install depends on. Node.js libraries are not compatible with react-native since it is not working on a Node.js platform.
To overcome this issue you can try to use react-native-http library, but I did not try to use it before, so I'm not sure if it's going to work or not.
So I am experimenting with nodejs, and have chosen frappe as a skeleton for learning (as I already use coffeescript on the frontend blah blah blah). Anyway I am just getting started and have encountered a problem, so noobish, I can't find an answer on google. The picture above should say it all.
What is wrong with my path to /config/globals ? I have tried:
./config/globals
/config/globals
globals
To no avail. What am I missing here?
path should be ./globals since you require a file from the same directory.
../config/globals would also work.
A require value with no path information looks for a module loaded by npm either locally inside node_modules, or in the global npm location.