Questions tagged [mjs]
40 questions
2
votes
2 answers
Fail to create variable using eval in Node.js ES6
It seems not possible to create a variable using eval in Node.js ES6 but I can't understand why. This happens to me on CentOS 7, but I don't believe OS is the problem here.
Regular Node.js file (test.js):
eval("var a=1");
console.log(a);
Make the…

Dee
- 7,455
- 6
- 36
- 70
1
vote
0 answers
Error importing mjs file into Typescript: TS2307: Cannot find module '../../env.mjs' or its corresponding type declarations
Using this library: https://env.t3.gg/docs/nextjs to build env validator in nextjs. I am getting following error on "yarn dev": TS2307: Cannot find module '../../env.mjs' or its corresponding type declarations.
I can successfully run the app, but…

Prashant Singh
- 13
- 2
1
vote
2 answers
MIME type of .mjs files is "text/html" when deploying React (ViteJS) app to Azure Kubernetes
I've built a React application utilizing ViteJS with TypeScript. I've built the project using tsc && vite build. I've then built the Docker image based on my Dockerfile:
FROM node:18.12.0
COPY build /build
RUN npm i -g serve
CMD ["serve", "-s",…

Akusas
- 480
- 1
- 7
- 27
1
vote
0 answers
Is there any way of changing the relative path of a mjs file (to make it see a different node_modules folder)?
When I'm executing pure node.js scripts I can change the path where it searches for node_modules as the following:
export NODE_PATH="/home/user/node_modules"
node "/home/user/different/path/file.js"
This way, I can make scripts located inside…

raylight
- 447
- 4
- 17
1
vote
0 answers
Load a CJS module config inside another file
I'm trying to load a config inside a node module but I'm not sure which is a good practice to do it, I have this scenario:
A config my.config.js:
module.exports = {
content: [
'./src/**/*.{tsx,ts}',
],
}
Then I have a module cli.mjs is…

vitto
- 19,094
- 31
- 91
- 130
1
vote
1 answer
"@angular/cdk": "^12.2.0", mismatch with angular material "@angular/material": "^13.1.1",
Don't say "downgrade version" to this question. I cant do it because management want to maintain the latest versions. Is there any other alternatives...like converting mjs to js file in angular project?
Getting error during "ng serve"
My…

Siri
- 43
- 1
- 9
1
vote
0 answers
Webpack 3 and .cjs/.mjs files
Context
Our product is (sadly) still on Webpack 3. Hope to upgrade, but in the meantime, I am trying to use an npm library that bundles cjs, mjs and iffe files. (See package.json excerpt below).
The problem is that Webpack complains when I import…

Lucas Arundell
- 91
- 6
1
vote
1 answer
Which should have .mjs extension, the importing file or the exporting file, or both?
I have a silly doubt. Which file, the importing file, the exporting file or both should have the .mjs file extension?
Specifically for NodeJS.
I have searched the web but didn't get my exact answer.
Thanks in advance!

Valoruz
- 194
- 1
- 15
1
vote
1 answer
Jest test functions that define variables in it
I want to write some Jest tests for JavaScript functions in a .mjs file. Within these functions, variables are defined by calling other functions. For example:
export function getCurrentVideo() {
var currentVideo = VideoList.GetCurrentVideo()
…

Rowin_nb2
- 164
- 1
- 13
1
vote
1 answer
NodeJS require module namespaces
I thought about having my, on npmjs released, module split into 2 or more parts (versioned), but both easily requirable / importable.
The result should be:
//index1.js
const themodule = require('mymodule');
//index2.js
const themodule =…

BananaAcid
- 3,221
- 35
- 38
0
votes
0 answers
Node.js global variable error 'Uncaught TypeError: "object" is read-only'
I am trying to check if 'object' is saved in Local storage, and if it is then assign a global variable the object in a separate file, however, in the console it is saying Uncaught TypeError: "object" is read-only (local-storage already contains…

Cameron Shearer
- 142
- 1
- 10
0
votes
1 answer
Telegram bot: SyntaxError SyntaxError: Unexpected end of JSON input when I want to upload a video
I'm trying to do a telegram bot who send vidéo
import fetch from 'node-fetch'
fetch("https://api.telegram.org/bot/sendVideo", {
method: "POST",
headers: {
"Content-Type": "multipart/form-data",
},
body:…

Aekyios
- 3
- 1
0
votes
0 answers
Getting bluetooth to Microbit in Python
I am currently creating a program on a raspberry pi that will get the distance of the raspberry pi to a BBC Microbit. Once this Microbit has reached a distance of zero it will then move on to the next Microbit distance etc. To do this it will take…

b.man
- 41
- 3
0
votes
0 answers
How to React Typescript Functional Component Library?
I hope someone can tell me where I am going wrong in trying to get usable libraries
I have created a NPM project using create-react-app --format typescript, I then created the following structure:
|->tsconfig.json
|->package.json
|->config
…
0
votes
0 answers
Import Framer website to Blazor WASM -> not working
I am trying to import framer site to Blazor. If I copy paste whole framer site (which was exported only by saving HTML -> framer recommendation) to index.html its working. When I try to split it (head, scripts -> index.html and body -> Index.razor)…

Laftek
- 33
- 3