I tried to make a small app using peerjs but when I tried to import Peer from "peerjs", my code crash with:
Uncaught ReferenceError: assignment to undeclared variable parcelRequire
At http://localhost:8080/_snowpack/pkg/peerjs.js:20
I didn't find anything on internet. And I don't why snowpack is using parcel because I didn't install any plugin
I tried to import Peerjs with Skypack but it's same.
On the other hand, when I test to import another library, here I tested with canvas-confetti, it work. So I don't know why Snowpack doesn't like Peerjs
This is an issue with the peerJs library.
You can see the line of code that is causing this issue here
You could perhaps mitigate it by setting window.parcelRequire before importing the peerJs library. Consider filing an issue to peerJs's github.
There is a similar error in parcel-bundler https://github.com/parcel-bundler/parcel/issues/1401 used by the status-widget developed by Atlassian https://bitbucket.org/atlassian/statuspage-status-widget/issues/3/uncaught-referenceerror-parcelrequire-is
You can fix this by adding esModuleInterop: true and allowSyntheticDefaultImports: true to tsconfig.json
For Instance Fix
Add variable in
node_modules/
peerjs/dist/peerjs.js
var parcelRequire
instead of
parcelRequire
Related
I'm getting the error from the title in my Vue app with Vite. I seem to have tried everything that I could find online but nothing really seems to work in my case.
The problem started when I installed aws-sdk to connect to my linode bucket storage, and importing it like import aws from 'aws-sdk'.
I tried almost everything from this issue, and quite a few variants from that in vite.config.js that I found elsewhere.
When using the following in my vite.config.js it works in dev:
define: {
global: "window",
},
But gives me the following error in prod:
[vite]: Rollup failed to resolve import "aws-sdk" from "/var/www/html/kwigy/src/linode.js".
[...]
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
[...]
And that doesn't seem to be a good solution anyway according to what I found online.
Adding a script to the tag or making a file that imports the said script in main.js also works in dev but gives the same error in prod.
I also tried to install requirejs, to use it as const aws = require('aws-sdk') but I have to admit I do not really understand how to configure that from the docs.
Does anybody have a solution to my problem? I have been stuck for a full day on this now.
when i try to import pdf2json (3.0.1) in my node project (typescript) iam getting this error
Could not find a declaration file for module 'pdf2json'
Also i try to install #types/pdf2json for typescript and there is not available.
How i can solve this
install #types/pdf2json for typescript and there is not available.
Looks like you're right that there are currently no types available, but that's a work in progress and they may exist soon: https://github.com/modesty/pdf2json/pull/278
I am using
ember-cli: 3.4.3 ,
node js:10.16.3,
ember-resolver: 5.2.1
ember-serve work perfectly and give
Build successful (25929ms) – Serving on http://localhost:4232/
but on browser console the following error comes and unable to process further
Uncaught Error: Could not find module `ember-resolver` imported from `appName/resolver'
I tried deleting package-lock.json ,node-modules, clearing cache & reinstalling still the same
Can any one help on this please
Found the issue with one dependency in package.json
"ember-light-table": "2.0.0-beta.4"
It seems this version of ember table is not compatible with other ember dependencies
reverted it to "ember-light-table": "2.0.0-beta.3",
now it is working fine
upgrade ember-source to #3.17.1 or higher
I am using WPGulp to build my assets for a WordPress theme, but I am faced with a weird issue and unfortunately, I cannot find any solution.
My current problem is that the statements like import ModuleName from './modules/ModuleName' doesn't work, and I get an error message in the browser console like this: Uncaught ReferenceError: require is not defined
Inside the compiled source code, the line that has the problem is like that:
var _Router = _interopRequireDefault(require("../util/Router"));
I have try to customize the Gulpfile of the WPGulp to make it work, but I can't make fix it.
One of the solutions I tried, but didn't worked is to add the modules options in the #babel/preset-env properties and set all possible options amd, umd, systemjs, etc, but none of them worked.
Any idea on how to solve that problem? Am I doing something in wrong?
Thank you in advance.
You may need to upgrade Node and/or use --experimental-modules flag. You can also set an env var in your shell:
export NODE_OPTIONS="--experimental-modules"
I am encountering a weird build issue with typescript and #types/react. I have two typescript config files: one for files which use react, and one for those that don't. When building the portion of my project which doesn't use react, I see the following error:
node_modules/#types/react/index.d.ts(3508,58): error TS2304: Cannot
find name 'HTMLDialogElement'.
node_modules/#types/react/index.d.ts(3508,78): error TS2304: Cannot
find name 'HTMLDialogElement'.
node_modules/#types/react/index.d.ts(3782,72): error TS2304: Cannot
find name 'HTMLDialogElement'.
node_modules/#types/react/index.d.ts(3782,92): error TS2304: Cannot
find name 'HTMLDialogElement'.
I was able to reproduce the error with a minimal example:
node_modules/typescript/bin/tsc typescript/foo.ts --outDir static/js/src --module none
The file typescript/foo.ts is a minimal file I used to reproduce the problem, and is deliberately short:
function printNumber(n: number) {
console.log(n);
}
let x = 3;
x *= 4;
printNumber(x);
Note that foo.ts does not have any references to react whatsoever. The weirdest part of this is when I uninstall #types/react, the error messages go away.
What's going on?
EDIT: I found this issue which manifests when tsc version > 2.3.2. I downgraded tsc to version 2.3.2 but the problem persists.
As fair as I understand the typescript's policies, this is relative to the version you are using. When typescript 2.3.2 was out the definition for HTMLDialogElement was not included in #types/react, so you see this error. You can read more about this in this github issue.
Probably, even if you don't include React on your foo.ts, the typescript compiler will include and check all the definitions that you've got, even those in node_modules. This will explain why you have this error even without including React.
Now that I think about it, I don't event include the definitions that I wrote - but they're used by the transpiler.
I had the same issue on a project recently cloned yesterday; I fixed it by updating typescript to ^2.7.0.
I had the same problem. tried all the upgrades and downgrades mentioned here.but, nothing worked for me. finally ended up commenting out the 'dialog' from line number 3782 and 3508 in node_modules/#types/react/index.d.ts
This is only a quick fix.
I had the same issue (latest create-react-app, with typescript version 2.5.3) and after I ejected the app (npm run eject) and updated typescript by hand to current version in package.json to current 2.7.2 this works again.
Seems to be some very strange bug (on Windows) cause my college (same installation) doesn't have this bug. When searching for this, you will find it appearing every 2 month or so, so that I guess, that it is not only this issue ( https://github.com/Microsoft/TypeScript/issues/16880 ) Duma pointed to, cause the project we're working on started somewhere in December.