Error: Cannot find module './dist-tools/transform.js' from '/opt/atlassian/pipelines/agent/build/node_modules/aws-sdk' - node.js

Hi so we have something interesting happening in our builds.
Nothing regarding the gulp build script changed from our side for one of our projects. But suddenly today when we try to do a pipeline build on one of our repositories we get the following stacktrace error:
Error: Cannot find module './dist-tools/transform.js' from '/opt/atlassian/pipelines/agent/build/node_modules/aws-sdk'
at /opt/atlassian/pipelines/agent/build/node_modules/resolve/lib/async.js:128:35
at load (/opt/atlassian/pipelines/agent/build/node_modules/resolve/lib/async.js:147:43)
at onex (/opt/atlassian/pipelines/agent/build/node_modules/resolve/lib/async.js:172:17)
at /opt/atlassian/pipelines/agent/build/node_modules/resolve/lib/async.js:13:69
at FSReqWrap.oncomplete (fs.js:152:21)
Has anyone come accross this before? (we are using node 10.17 for our builds)
We tested the same code from our local builds and get the exact same issue. It seems that something in the aws-sdk package changed?
Since this error suddenly appeared this morning, we looked at our aws-sdk package and updated it to the latest version (2.643.0), but we still get the same error. No code that uses the aws-sdk package has changed.

Also seeing this as of this morning. I find this somewhat sus (adding dist-tools to npmignore).
https://github.com/aws/aws-sdk-js/commit/98c40e64cb7d60927c6a0cec49592fc1fcaa59d7
I wonder if pulling the package directly from GH would resolve.
UPDATE:
I've got a convo going on over here about this https://github.com/aws/aws-sdk-js/issues/3159
We downgraded to the previous version and our issue went away.

Related

Webpack loading wrong version of Node Module for Angular project

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.

angular project npm modules randomly deleted

I have the weirdest problem I've ever seen with npm where in the middle of running an angular ng serve, packages from both node and for angular will randomly go missing. In the middle of a save, the project will suddenly not recompile, and will complain about a missing module. Each time it has been different but so far I have had:
Error: ENOENT: no such file or directory, open '.../node_modules/core-js/internals/hidden-keys.js'
Module not found: Error: Can't resolve '../internals/is-pure' in '/.../node_modules/#angular-devkit/build-angular/node_modules/core-js/internals'
An unhandled exception occurred: Cannot find module './internal/streams/stream
An unhandled exception occurred: Cannot find module '/.../node_modules/minipass-collect/node_modules/minipass/index.js'.
Please verify that the package.json has a valid "main" entry
These have just been errors from the last few days, but issues like this has been happening all. to the point where I need to delete node_modules and reinstall everything via npm at least once a day. I'm thinking the error has more to do with node or NPM than with my Angular set up, as some of these missing packages appear to be node core packages.
I've already tried reinstalling npm globally via npm install -g npm and it hasn't helped anything. I'm afraid that I'm going to have to just reinstall node completely.
Any help would be appreciated, thank you.
EDIT: upon further debugging, I'm noticing that the modules missing are always from #angular-devkit/build-angular/node_modules/core-js/modules. In addition to losing random modules like 'is-pure', the app will also randomly recompile many times when running ng serve
I figured out what was going on, if anyone in the future has the same problem. Turns out the answer has nothing to do with me botching my npm config. I didn't realize that on new Macbooks, any directory in the desktop is automatically managed by iCloud. At some point, probably an older version of the code before I migrated to Angular 9 was syncing the old code into my project. I was able to resolve this issue by changing the name of the parent directory where my project lived from filename to filename.nosync. adding '.nosync' causes iCloud to ignore syncing for whatever is in that file. I know I should have caught this, but hopefully this will help any mac users in the future who are experiencing similar problems.

Node Sass error in Angular: Mixins may not be defined within control directives or other mixins

I have a project written in Angular 4 and I am trying to build it, but I keep getting this error: Mixins may not be defined within control directives or other mixins.
I've looked around on the internet and I saw some recommendations to downgrade node-sass to the version 4.8.1, but when I tried to do this, I got a 404 erro from Github:
> node-sass#4.8.1 install c:\my-project\node_modules\node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.8.1/win32-x64-64_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.8.1/win32-x64-64_binding.node":
HTTP error 404 Not Found
And sure enough, this address: https://github.com/sass/node-sass/releases/download/v4.8.1/win32-x64-64_binding.node doesn't exists. My guess is because there are new versions of node-sass available and the 4.8.1 was pushed back to the second page: https://github.com/sass/node-sass/releases?after=3.5.3.
I know that I am using a very old version of Angular and I have plans to upgrade it, but I don't have the time to do this now, has someone managed to solve this?
Download win32-x64-64_binding.node, put in the local:
C:\Users\{username}\AppData\Roaming\npm-cache\node-sass\4.8.1\
Then install again.

Twilio Video Startup

I am fairly new to React and am trying to run an example to get started with understanding how Twilio interfaces with React/Node. I am currently using the repo https://github.com/twilio/twilio-video.js, and am trying to run the test > framework > twilio-video-react, but when I npm install then npm start, the server starts, but throws the error:
Failed to compile
./src/App.js
Module not found: Can't resolve 'twilio-video'
I did `npm install twilio-video`, but still throwing error. What am I missing here? Can anyone else get this example started? I want a base example with Twilio Video working with React so I can learn from there, any other resources would help, thanks!
I tried these two examples as well, but they are outdated:
https://www.twilio.com/blog/2018/03/video-chat-react.html
https://www.twilio.com/blog/2016/03/building-a-react-powered-video-chat.html
Okay, got an example up and running with a little fudging.
I followed this example: https://www.twilio.com/blog/2018/03/video-chat-react.html
But there were a few old libraries that were causing errors.
Posted a working version on my Github linked here.

Node.js module "fibers" not taking the correct version

I'm pretty new to node.js and its package management system and its require. I'm having trouble with the following runtime error I'm getting after having installed a bunch of packages with npm install:
ERROR: Couldn't initialise framework "wdio-mocha-framework".
Error: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found
(required by <path>.../node_modules/fibers/bin/linux-ia32-v8-5.0/fibers.node)
at Error (native)
My understanding of the error is that the binary fibers.node was compiled with a newer libstdc++ than the one available at runtime.
It appears to me like the npm install did compile a fibers.node:
> fibers#1.0.13 install <path>.../node_modules/fibers
> node build.js || nodejs build.js
make[1]: Entering directory `<path>.../node_modules/fibers/build'
<snip some output, including warnings, here that I don't deem relevant>
Installed in `<path>.../node_modules/fibers/bin/linux-ia32-v8-3.14/fibers.node`
However, I see that the fibers.node that is throwing the error at runtime is not the same one as was compiled, and I assume that's the source of the problem.
Compiled:
.../linux-ia32-v8-3.14/fibers.node
Used at runtime and fails:
.../linux-ia32-v8-5.0/fibers.node
So I'm guessing and hoping that if I could convince wdio-mocha-framework to use the locally-compiled fibers.node, it would work. My questions are thus:
Would that fix it?
If so, how do I achieve that?
If not, what's the correct direction to take to further understand and fix this error? Perhaps instead of getting 3.14 to be used at runtime, I should be convincing 5.0 to be compiled at install-time? Or ... other?
Your help is most sincerely appreciated.
Update/Edit:
I think I solved this on my own, in case anyone ever finds this poor, dusty old question lying forgotten on the back of a shelf somewhere...
The problem was apparently due to multiple versions of node/node-gyp that were installed in my environment in parallel, and the build process, even though it was started with a newer version of node, was finding node-gyp in the $PATH and that's apparently what caused the old version of fibers to be built. At least, I think so.
Just had this problem recently. I managed to solve it just by uninstalling the current version of Node.JS (I had the most recent, in this case 9.5.0) and installing the recommended, in this case 8.9.4. and the issue is gone. hope this helps someone.

Resources