I have encountered a few times that either the babel loader in webpack begins throwing errors unexpectedly despite nothing directly relating to webpack or babel etc being altered. As an example I was recently unable to compile due to babel not being able to handle private methods in classes, despite this supposedly being covered as part of babel 7.14+
ERROR in ./node_modules/pdfjs-dist/build/pdf.js 1413:9
Module parse failed: Unexpected character '#' (1413:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| class PDFDocumentLoadingTask {
> static #docId = 0;
|
The problem persisted even after I rolled back changes to the previous working commit and in the end I was only able to get webpack to compile after reinstalling all npm packages.
What are the possible causes of this?
Related
I'm new to using cloudflare and wrangler. I've a project that I've been working on, and I'm now trying to deploy it using wrangler publish, but I keep running into issues. My product is coded in node.js, and I'm using version 2 of wrangler. When I execute wrangler publish I get:
Basic JavaScript project found. Skipping unnecessary build!
Error: Something went wrong with the request to Cloudflare...
Uncaught SyntaxError: Cannot use import statement outside a module
at worker.js:2Basic JavaScript project found. Skipping unnecessary build!
Error: Something went wrong with the request to Cloudflare...
Uncaught SyntaxError: Cannot use import statement outside a module
at worker.js:2
I've searched for a solution, and one of them that I found said to change module in wrangler.toml from type="javascript"to type="webpack" however that gives me a bunch of errors:
./node_modules/destroy/index.js
Module not found: Error: Can't resolve 'fs' ... Parsed request is a module...resolve as module
/Users/Desktop/APIs/cpiCalculator2/node_modules/destroy/node_modules doesn't exist or is not a directory
...
Error: webpack returned an error. You may be able to resolve this issue by running npm install.
I've tried reinstalling npm as it suggests and then wrangler publish again, but that just gives me the same error message.
I'm really not sure what the issue is, and I would really appreciate any help or advice on how to resolve this issue. Thank you!
Also, just a note, I'm not sure if this is affecting it, but I do have two other js documents in the main area of my project (where my index.js file is).
I created a fresh project using CRA, and then added a custom eslint config with a single rule, no-console, and set it to error log level.
When running yarn start to do development, and putting in a console log, the whole build fails and I get a generic error page saying the build failed because there was a console log. But, I put the log there to debug the app, and this isn't a production build.
I also tried seeing if this could be related to custom eslint configs so I violated the rule-of-hooks rule that is default with CRA and saw the same thing happen.
How can I develop with a linting error present?
Failed to compile.
./node_modules/core-js/modules/es.regexp.exec.js 1:3
Module parse failed: Unexpected character '' (1:3)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders (Source code omitted for this binary file)
This happens when I turn off the screen of the laptop for a while
I tried uninstall / re-install Node, NPM Several Times
and now I tried to use Yarn but still the same problem happens
While Running arc lint on a service
I am seeing this error
Exception
Some linters failed:
- Exception: Linter failed to parse output!
STDOUT
STDERR
<standard input>:40:1: expected statement, found 'package'
<standard input>:59:27: expected ';', found error
(Run with `--trace` for a full exception trace.)
It suddenly started happening.
I was facing a similar issue. Here was the observation to fix the same. Whenever you do execute lint it automatically adjusts the code accordingly. In case if the new line is not present in the end of the file, lint copied the entire file so code become like below
package mypackage
import (
"go.uber.org/fx"
)
// Module is an FX module used when initializing the app
var Module = fx.Provide(
NewNewClient,
package mypackage
import (
"go.uber.org/fx"
)
// Module is an FX module used when initializing the app
var Module = fx.Provide(
NewNewClient,
)
Note that package is repeated here hence cause the issue.
I created a new aurelia project and installed gojs via npm. I added gojs to the aurelia.json dependencies and, without adding any gojs code, just tried to build the project. The build worked fine and gojs went to the vendor-bundle.js The issue is, when I run the project, I get an error from gojs. When I remove the gojs dependency in aurelia.json, the project runs just fine but adding it back always throws the same error located below. Please help.
Uncaught Error: Mismatched anonymous define() module: [object Object]
http://requirejs.org/docs/errors.html#mismatch
at makeError (vendor-bundle.js:11531)
at intakeDefines (vendor-bundle.js:12617)
at vendor-bundle.js:12815
makeError # vendor-bundle.js:11531
intakeDefines # vendor-bundle.js:12617
(anonymous) # vendor-bundle.js:12815
setTimeout (async)
req.nextTick # vendor-bundle.js:13178
localRequire # vendor-bundle.js:12812
requirejs # vendor-bundle.js:13160
(anonymous) # vendor-bundle.js:13199
(anonymous) # vendor-bundle.js:13508
To clear up some confusion here, you're talking about declaring the dependency in aurelia.json which implies you're using aurelia-cli in conjunction with the requirejs loader.
jmdavid's answer mentions webpack which is a different beast altogether. You don't declare dependencies in aurelia.json there; webpack resolves those by itself via the imports it finds in your entry file. I would actually recommend switching to webpack for various reasons; the fact that it would fix the error is just one of them.
The error is likely caused by the go.js module being loaded twice. The error throws on the second load; it should still work regardless of the error. You can't make the error go away in any straightforward manner with requirejs, this is due to how the go.js release is packed.
The only error-free way to load go.js here would be to do so before requirejs is loaded. In aurelia.json:
"node_modules/gojs/release/go.js",
"node_modules/requirejs/require.js"
And no need to import it then either, it will just be available globally.
Probably the versions are oudated on fedoranimus github (https://github.com/fedoranimus/aurelia-gojs).
I made it work by creating a new project with the cli (au new) with webpack and typescript, then npm installed gojs (version "^1.8.15"), then copied relevant code from fedoranimus.