TypeError while instantiating Auth0Lock on yarn app - yarnpkg

I have downloaded the official lock repo: https://github.com/auth0/lock
I run the examples and they all work fine.
When I try and run the same code inside my Yarn project like so:
const cid = 'redacted';
const domain = 'redacted.auth0.com';
const lock = new Auth0Lock(cid, domain);
lock.show();
I get the following error:
TypeError: l.setup is not a function
at setupLock (app-root.entry.js:38263:13)
at Auth0Lock.Base (app-root.entry.js:47258:37)
at new Auth0Lock (app-root.entry.js:47517:56)
at AppRoot.auth0Login (app-root.entry.js:49538:20)
at AppRoot.handleLoginEvent (app-root.entry.js:49531:10)
at HTMLDocument.<anonymous> (index-64bf1dc2.js:94:51)
There are no references to this error on the internet except this post from 2017:
https://github.com/rollup/rollup-plugin-node-resolve/issues/87
The reporter kylecombes made a fork with substantial changes to fix the issue, but that fork is now quite out-of-date.
Because the example code is so terse, I'm not sure what else to try. I am concerned that its a compatibility issue between Yarn and Auth0/lock. Their only examples are in webpack and browserfy.
Any help would be greatly appreciated.

Related

`Cannot use e "__Schema" from another module or realm.` and `Duplicate "graphql" modules` using ApolloClient

I have a React application with ApolloClient with Apollo-Link-Schema. The application works fine locally but in our staging environment (using GOCD), we get the following error:
Uncaught Error: Cannot use e "__Schema" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
at t.a (instanceOf.mjs:21)
at C (definition.mjs:37)
at _ (definition.mjs:22)
at X (definition.mjs:284)
at J (definition.mjs:287)
at new Y (definition.mjs:252)
at Y (definition.mjs:254)
at Object.<anonymous> (introspection.mjs:459)
at u (NominationsApprovals.module.js:80)
at Object.<anonymous> (validate.mjs:1)
Dependencies are installed with yarn, I've added the resolutions field to the package.json.
"resolutions": {
"graphql": "^14.5.8"
},
I've checked the yarn.lock and can only find one reference for the graphql package.
npm ls graphql does not display any duplicates.
I thought maybe its a build issue with webpack - I have a different build script for staging, but running that locally I am still able to get the react application to run with that bundle.
Can anyone suggest anything else to help me fix this?
I managed to find the cause of the issue, if this helps anyone else. The issue is not to do with duplicate instances of the package at all, this is a false positive triggered by us using webpack's DefinePlugin to set the process.env.NODE_ENV to staging for our staging build.
However, in webpack the mode (see https://webpack.js.org/configuration/mode/), which sets the process.env.NODE_ENV, only accepts none, development and production as valid values. This was triggering an env check in the graphql package to fail and trigger this error message.
In our case, we need to differentiate between staging and production as our API endpoint differs based on this, but the solution we implemented is to not rely on the process.env.NODE_ENV, but to assign a custom variable on build (e.g. process.env.API_URL)
I would try to replicate the error locally and debug it:
try this:
rm -rf node_modules yarn.lock
# also remove any lock files if you have package-lock.json too
yarn install
# build the project locally and see if you got the error
I got this problem one time where I was working with Gatsby and 2 different themes where using different versions of GraphQL. Also be more explicit with the version (without caret) and check if the error persist.
do you have a repo youc an share? that would also help us to help you :)
While changing NODE_ENV to production might solve the issue, if you have different variables for each environment and don't want to mess with your metrics this is not an ideal solution.
You said you use webpack. If the build with the issue uses some kind of source-map in your devtool, you might want to disable that to see if the problem persists. That's how I solved this without setting my NODE_ENV to production.
I had a similar problem when trying to run Apollo codegen and was able to fix it by deduping my npm packages. Run this:
rm -rf node_modules && npm i && npm dedupe
I was having this problem so I switched to yarn, and after deleting node_modules and npm lockfile, then running yarn, the problem went away :-).
I ended up here because I use the AWS CDK and the NodejsFunction Construct. I was also using bundling with minify: true.
Toggling minify to false resolved this for me.

Is there a way to make RichEmbed methods work in Heroku?

When attempting to use this code I got the error below:
const embed = new RichEmbed();
var num = Math.floor(Math.random() * 10);
let name = part + num + ".gif";
embed.attachFiles([name]);
embed.setImage('attachment://' + name);
mess.channel.send(embed);
TypeError: embed.attachFiles is not a function
I if I delete away embed.attachFiles([name]) I get an error saying that embed.setImage isn't a function either.
Is there anything I can do to make Heroku register these as functions? It is worth noting that this worked outside of Heroku, when I ran it using the command line on my own computer.
Heroku by itself does not modify the behavior of discord.js. Here's a list of things you can try:
Verify that your package.json file is updated with the version of discord.js you want and run npm i to make sure the version on your pc is the same*.
Make sure that RichEmbed is Discord.RichEmbed: try to write it explicitly to see if that helps.
Try to console.log(embed) and see what gets logged in the console: that might give you a clue of what the problem is...
* The RichEmbed.attachFile() method was added in the 11.0.0 version: any previous version of discord.js won't allow you to use it.

How does serverless know where to find the serverless.yml?

How does npm/yarn serverless packageadded locally in a project know where to locate the serverless.yml file?
I am trying to locate the exact piece of code in the source code of serverless framework ( https://github.com/serverless/serverless), where this happens, but haven't had any luck so far.
I need to know this because my
yarn sls offline start
command does not seem to the new changes that i did in serverless.yml file.
It keeps picking the old one.
This is the code used by Serverless to load the configuration:
https://github.com/serverless/serverless/blob/master/lib/utils/getServerlessConfigFile.js#L9
Relevant excerpt:
const servicePath = srvcPath || process.cwd();
const jsonPath = path.join(servicePath, 'serverless.json');
const ymlPath = path.join(servicePath, 'serverless.yml');
const yamlPath = path.join(servicePath, 'serverless.yaml');
const jsPath = path.join(servicePath, 'serverless.js');
return BbPromise.props({
json: fileExists(jsonPath),
yml: fileExists(ymlPath),
yaml: fileExists(yamlPath),
js: fileExists(jsPath),
}).then(exists => {
Note that from the CLI servicePath is set to the current working directory.
Looking at the code, my guess is that you may have a serverless.json which takes precedence over serverless.yaml? The command serverless print will show your resolved configuration. (https://serverless.com/framework/docs/providers/aws/cli-reference/print/#print)

'a is undefined' when compiling a cljs prj with an NPM module under :prod profile

I followed this howto: http://blob.tomerweller.com/reagent-import-react-components-from-npm and it worked great. I even managed to use one of my own NPM module on top of this example app of re-frame: https://github.com/Day8/re-frame/tree/master/examples/simple/
Starting the resulting app with:
lein clean && lein figwheel
everything works ok, but when I do:
lein do clean, with-profile prod compile
I get a TypeError: a is undefined. Any idea to fix this?
Let me provide you with the code: the bad commit is here,
while both :dev and :prod profiles work OK at this just previous commit.
Update: I managed to fix the compiled version like this (see the commit):
return d.c?d.c(c,v,w):d.call(null,c,v,w)}}(G,r,b,c,d,e)),I=dw(G);rf.b?: […]
};w.b=v;w.c=f;return w}()}(c,d,e,f))};hf.b(ow,ik);hf.b(ow,bp);hf.b(ow,To); […]
function nx(a){var b=window.deps["react-mathjax"],
- c=window.deps.clubexpr.kf;
+ c=window.deps.clubexpr.renderLispAsLaTeX;
return new U(null,3,5,V,[Vj,b.Context,new U(null,4,null)}
function Wv(){return function(a){return function(){return new U(null,6,5,V,[…]
This seems to me a compilation misconfiguration or bug.
Update 2: my code compiles OK if I set :optimizations to :simple (was :advanced). See the cljs compiler doc about this option.
Thanks.
The code that is failing is here.
It looks like you might need to provide externs for clubexpr, so that the Closure Compiler knows not to rewrite renderLispAsLatex as kf. When compiling under :simple, the Closure Compiler doesn't rewrite function names, so this problem wouldn't show up.
As a side note, you probably shouldn't use aget to get objects from the window, aget is designed for array access only. To get objects, you should use goog.object/get. See this post on Checked Array Access for more info on this.

gulp watch in laravel elixir not working globule.js undefined indexof

I have a Laravel project in Ubuntu 16.04.
It is an existing project where the gulpfile.js is working properly on another system.
My problem is the gulp watch is not working at only this error is showing up:
TypeError: Cannot read property 'indexOf' of undefined
at /usr/lib/node_modules/gulp/node_modules/globule/lib/globule.js:25:16
at Array.reduce (native)
at processPatterns (/usr/lib/node_modules/gulp/node_modules/globule/lib/globule.js:24:30)
at Object.globule.find (/usr/lib/node_modules/gulp/node_modules/globule/lib/globule.js:76:17)
at Gaze.add (/usr/lib/node_modules/gulp/node_modules/gaze/lib/gaze.js:174:19)
at new Gaze (/usr/lib/node_modules/gulp/node_modules/gaze/lib/gaze.js:74:10)
at gaze (/usr/lib/node_modules/gulp/node_modules/gaze/lib/gaze.js:86:10)
at Object.module.exports [as watch] (/usr/lib/node_modules/gulp/node_modules/glob-watcher/index.js:12:17)
at Gulp.watch (/usr/lib/node_modules/gulp/index.js:40:14)
at /home/vagrant/votingmp/node_modules/laravel-elixir/dist/tasks/recipes/watch.js:26:18
Has anybody ever had the same problem? I can't seem to find any solution regarding this
Cannot read property 'indexOf' of undefined
at /usr/lib/node_modules/gulp/node_modules/globule/lib/globule.js:25:16
Any helps appreciated!
I have same problem with you, then I realize that one of my script files gen errors, so just remove it from mix.scripts([]) array, unless please check your gulp.js content.

Resources