when i run npm start i got this error Le programme « npm.cmd » n’a pas pu s’exécuter
im trying to start the project
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
when i run npm start i got this error Le programme « npm.cmd » n’a pas pu s’exécuter
im trying to start the project
My site shows users their results on a quiz. The results are returned from a SQL database.
I have confirmed that the data is being returned correctly and as the correct type (integer).
The text fields are being added as expected however for the percentage bar (user’s score), only the first one loads correctly.
My code in php file:
$(document).ready(function() {
$width = $("#myResultBar").data('width');
$("#myResultBar").css("width", $width + "%");
});
</script>
My and <?php code that only does the first display with percentage bar correctly:
<?php
for($i = 0; $i < count($life_ins_quiz_chapter_num); $i++){
?>
<!-- results box -->
<div class="result_box">
<h3 class="hd text-center">Chapter: <?php echo $life_ins_quiz_chapter_num[$i];?></h3>
<p><?php echo $life_ins_quiz_chapter_desc[$i];?></p>
<div class="row align-items-center">
<div class="bar_main col-sm-11 col-9">
<div id="mySaving" class="bar">
<div id="mySavingBar" data-width="<?php echo $life_ins_quiz_chapter_pct[$i];?>"></div><!--problem here-->
</div>
</div>
<div class="percent col-sm-1 col-3">
** <!--This only shows up the first time. What am I doing wrong?-->**
<?php echo $life_ins_quiz_chapter_pct[$i]; ?> %
</div>
</div>
<div class="box_analysis">
<h3>Question Score: <?php echo "[ " . $life_ins_quiz_chapter_score[$i] . "/6 ]"; ?> </h3>
<?php //echo $saving_report_detail; ?>
</div>
</div>
<?php
}//end for
?>
I have:
1-Done multiple checks to get the correct data type into that variable gettype(variable) = integer
2-Could not figure out if there was a way to change something in the js to have it increment the id
(for e.g. #MySavingBar_1(2,3)etc..
Open to any guidance or suggestions.
I have 3 inputs: an array, a total count integer and an arbitrary value.
input_array = ['hello', 'there', 'world']
total_count = 15
fill_value = null
Desired output:
output = [
'hello',
null,
null,
null,
null,
'there',
null,
null,
null,
null,
'world',
null,
null,
null,
null,
]
Assume that the length of input_array does not exceed total_count. Other scenarios:
total_count was 3, you’d get ['hello', 'there', 'world']total_count was 4, you’d get ['hello', null, 'there', 'world']This feels like a candidate for a recursive function? You could take Math.ceil((total_count - input_array.length) / input_array.length) and use that value to fill in the slots but I’m not sure what the cleanest syntax would look like.
I would like to run a script in the browser console that will open an array of url’s one by one with a few seconds delay between them, better if in the same tab, will copy some data from the page and will insert it into a file and download it after finishing the url’s.
This is what I got so far, but still not working.
Do you know of any alternative to get the this result?
Thanks for the answers.
// website lists
const urlList = ['https://stackoverflow.com/questions/237104/how-do-i-check-if-an-array-includes-a-value-in-javascript?rq=1', 'https://stackoverflow.com/questions/586182/how-to-insert-an-item-into-an-array-at-a-specific-index-javascript?rq=1', 'https://stackoverflow.com/questions/5767325/how-can-i-remove-a-specific-item-from-an-array-in-javascript?rq=1'];
const writeToTextFile = (text, fileName) => {
let textFile = null;
const makeTextFile = (text) => {
const data = new Blob([text], {
type: 'text/plain',
});
if (textFile !== null) {
window.URL.revokeObjectURL(textFile);
}
textFile = window.URL.createObjectURL(data);
return textFile;
};
const link = document.createElement('a');
link.setAttribute('download', fileName);
link.href = makeTextFile(text);
link.click();
};
// variable for keeping track of array position(urls)
let fileData = '###';
let i = 0;
// create interval with 10seconds delay and keep
// interval reference to clear the event in future
let int = setInterval(() => {
// update the location with next array value
// open the first url and cache the window object reference
let win = window.open(urlList[i], "_blank")
// check value of i and increment, if reached the max value then clear the interval
setTimeout(function execute() {
console.log(win.document.getElementsByTagName("h1"));
fileData = fileData + "###"+win.document.getElementsByTagName("h1");
}, 3000);
if (i++ >= urlList.length) {
writeToTextFile(fileData, 'output.txt');
clearInterval(int);
}, 6000)
}
I am trying to use Nuxt Content to create a blog section of my website. I have created the directory structure and some testing posts. I have also created the query that grabs the posts and stores them as a ref so they can be used on the page. My issue is that the components I see on the page do not match what is returned by the Nuxt Content query
Snippet
<script setup>
const { data: recentBlogPosts } = await useAsyncData(`content-${path}`, () => {
return queryContent()
.only(['title', 'excerpt', 'created', 'updated', 'slug', 'tags', '_id'])
.limit(5)
.sort({ 'updated': -1 })
.find()
})
index.vue Page Snippet
<nuxt-link v-for="post in recentBlogPosts" :key="post._id" :to="`blog/${post.slug}`">
<BlogPostShort class="blog-post-short"
:title="post.title"
:createdDate="post.created"
:updatedDate="post.updated"
:excerpt="post.excerpt"
:tags="post.tags" />
</nuxt-link>
The resulting website output on the page

An image of Vue DevTools showing only 5 components produced by v-for directive

I have tried adding a :key="post._id" to the code but that hasn’t solved anything. I thought giving Nuxt a means of tying a post to the data on the backend might help it but sadly no such luck
I’m evaluating Axios and one thing I can’t seem to figure out how to enforce that a response is JSON. From what I’ve gathered, Axios will automatically parse the JSON for us based on the content type (https://stackoverflow.com/a/65976510/1103734). However, I was hoping to actually enforce that the response is JSON (e.g. if my nginx proxy returns HTML due to a downstream error, I would want to handle that).
I noticed that the Axios request config has a responseType property, but as near as I can tell, this is not used to actually enforce an expected type is returned. Here’s an example snippet that demonstrates what I’m talking about
axios.get('http://cataas.com/cat?html=true', {responseType: "json"})
.then(res => console.log(`Response:n ${res.data}`))
.catch((err) => console.log(`Error: ${err}`))
Output:
Response:
<!DOCTYPE html>
<html lang="en">
<header>
<meta charset="utf-8">
</header>
<body>
<img alt="GRxZb4kUHleQ3LhC" src="/cat/GRxZb4kUHleQ3LhC">
</body>
</html>
The best thing I can find is to put JSON.parse in the transformResponse property, but this means that if there’s an error in parsing a response with a bad status code, I will lose that status code information in my catch.
axios.get('http://cataas.com/cat?html=true', {responseType: "json", transformResponse: JSON.parse})
.then(res => console.log(`Responsen ${res.data}`))
.catch((err) => console.log(`Error: ${err}`))
Output (obviously, SyntaxError does not contain any information about the response):
Error: SyntaxError: Unexpected token < in JSON at position 17
Is there a nice way to achieve what I want?
I’m trying to zoom in/out while scrolling down/up using ScrollMagic, currently, while I try to scroll down to zoom in on the image, it works, but after it’s completely zoomed in, trying to scroll up to zoom out has no effect, how to fix the problem? I’ve tried various approaches but can’t get this to work, someone please help!
html
<div class="wrapper">
<div class="test">
<img src="../media/moon.png" class="moon">
</div>
</div>
css
.wrapper {
display: block;
width: 50%;
height: 200vh;
z-index: 2;
}
.test {
overflow: hidden;
width: 100%;
height: 100%;
}
.moon {
width: 100%;
height: 100%;
display: block;
object-fit: cover;
}
.change {
transform: scale(1.3);
transition: 2s;
}
js
var controller = new ScrollMagic.Controller();
var scene = new ScrollMagic.Scene({
triggerElement: '.moon',
triggerHook: 0,
offset: 50,
})
.setClassToggle('.moon', 'change')
.addIndicators()
.addTo(controller);
I’m using javascript and here is the problem statement
const sourceArray = [3, 6, 9]
const elementsToGenerate = 10
expected output is random numbers from sourceArray till the length of the output array is 10 and should have at least 1 of each element from sourceArray and should be spread almost evenly
example output 1 [3,9,6,6,3,9,6,3,3,9]
example output 2 [9,6,3,9,6,9,3,9,3,6]
I’m trying to route the user on login to a page depending on data I get from a useQuery call , but the onSuccess is too quick to run while the query hasn’t fetch yet , my code looks like this
const { data, refetch } = useQuery(["tracks"], getTracks, {
enabled: false,
});
const { mutate, isLoading, isError, error } = useMutation(login, {
onSuccess(d, v, c) {
Cookies.set("cookieToken", d?.access);
let type = Cookies.get("cookieToken");
type = parseJwt(type);
type = type.user_type;
refetch();
if (data) {
if (type === 5 || type === 6) {
navigate(`/${data?.object[0]?.id}?type=prio`);
} else {
navigate(`/${data?.object[0]?.id}?type=filtering`);
}
}
},
});
I want to onSuccess of the use mutation to fetch the query , wait for the result and navigate the user based on the data I get from the query , how to do so ?
I can’t run the useQuery before the onSuccess because it won’t succeed without having the token from the mutation
As a beginner with basic knowledge of HTML and JavaScript, what are some ways to improve my skills in JavaScript and learn Python?
I’m currently following online courses like Skillshare, but I feel like the learning experience would be more engaging and creative if I could test my own coding skills instead of just reproducing pre-made projects. Are there any resources or platforms that allow for more interactive and hands-on learning?”
I have a question about javascript within Jinja2 before I start on my project, so I can understand if jinja is the right solution to use
I want to create an html email template that will fill in some values for each user, and then send them the rendered template via email. I already have the email functionality set up
I want to include some charts from chart.js on the page, but because JS isn’t allowed on emails I have to convert the charts to images before sending the email.
Assume a document on Firebase Firestore representing a house
{
id: "1234",
owner: "John",
address: "123 Something Ave.",
residents: [],
}
I have a cloud function that is supposed to add residents to the house.
Also note: the residents field isn’t always there from the start. Idea is to add it when the first resident is added.
This is my operation, which is part of a cloud function:
db.collection("houses")
.doc(house_id)
.set(
{
residents: admin.firestore.FieldValue.arrayUnion({
uid: context.auth.uid,
first_name: driverData.first_name,
last_name: driverData.last_name,
}),
},
{ merge: true }
);
But instead of creating this field with the array an leaving all the other data in the document, the function completely removes all the other data and I am only left with the residents array field.
Why is that?
I was trying to use my model to display and find users from the MongoDB,
But when I import it into profile.js and start my App it gives me an Error saying
Note I Tried using it with the API and It works fine, Idk why it’s like this with my Component,
It’s weird to me because I never had this Error before, Anyone know how to fix it or why it’s showing this Error?
My code
connect.js
import mongoose from "mongoose";
export default async function connect(){
try{
const {connection} = await mongoose.connect(process.env.MONGODB_URL)
if(connection.readyState = 1){
return Promise.resolve(true)
}
}catch(err){
return Promise.reject(err)
}
}
user.js
import {Schema, models, model} from "mongoose";
const usersSchema = new Schema({
...
})
const Users = models.Users || model('Users', usersSchema)
export default Users
profile.js
import { useState, useEffect } from 'react'
import {signOut, useSession} from 'next-auth/react'
import connect from "@/database/connect"
import Users from "@/database/schema/users"
export default function Profile(){
const [loaded, setLoaded] = useState(false)
useEffect(() => {
setLoaded(true)
}, [])
const {data: session} = useSession()
console.log(session)
useEffect(() => {
const userSession = session.user?.email
if(session){
const checkUserInfo = async() => {
const findUser = await Users.findOne({ email: session.user?.email })
console.log(findUser)
}
checkUserInfo()
}
}, [])
}
When I run:
npm run dev
I get those 36 Errors saying wierd text no one faced it before
starting with this:
C:Windowssystem32cmd.exe [15836]: c:wssrcmodule_wrap.cc:599: Assertion `(it) != (env->id_to_function_map.end())' failed.
I searched for 3 days and found nothing!
This is the error in cmd
This is my package.json file
I struggled founding the solution!
Ran this command
npm run dev
I expected it to run the server for my next.js project
and this is the error it shows
`C:Windowssystem32cmd.exe [15836]: c:wssrcmodule_wrap.cc:599: Assertion `(it) != (env->id_to_function_map.end())' failed.
1: 00007FF6FC8D22FF node_api_throw_syntax_error+180191
2: 00007FF6FC8569D6 v8::internal::wasm::WasmCode::safepoint_table_offset+61942
3: 00007FF6FC856DB2 v8::internal::wasm::WasmCode::safepoint_table_offset+62930
4: 00007FF6FC897520 v8::internal::ReusableUnoptimizedCompileState::ast_raw_string_zone+9696
5: 00007FF6FD2553AD v8::internal::Isolate::RunHostImportModuleDynamicallyCallback+605
6: 00007FF6FCEBAFD4 v8::internal::Runtime::SetObjectProperty+2548
7: 00007FF6FD43FC0C v8::internal::SetupIsolateDelegate::SetupHeap+607212
8: 00007FF6FD4ED0A5 v8::internal::SetupIsolateDelegate::SetupHeap+1316997
9: 00007FF6FD3B7330 v8::internal::SetupIsolateDelegate::SetupHeap+47888
10: 00007FF6FD3EEE58 v8::internal::SetupIsolateDelegate::SetupHeap+276024
11: 00007FF6FD498985 v8::internal::SetupIsolateDelegate::SetupHeap+971109
12: 00007FF6FD3DECE0 v8::internal::SetupIsolateDelegate::SetupHeap+210112
13: 00007FF6FD3B59AB v8::internal::SetupIsolateDelegate::SetupHeap+41355
14: 00007FF6FD265CA0 v8::internal::Execution::CallWasm+1664
15: 00007FF6FD265DBB v8::internal::Execution::CallWasm+1947
16: 00007FF6FD266B6A v8::internal::Execution::TryCallScript+346
17: 00007FF6FD23E6E2 v8::internal::MicrotaskQueue::RunMicrotasks+370
18: 00007FF6FD23E4AA v8::internal::MicrotaskQueue::PerformCheckpointInternal+74
19: 00007FF6FC90680E node::CallbackScope::~CallbackScope+414
20: 00007FF6FC906CB0 node::CallbackScope::~CallbackScope+1600
21: 00007FF6FC8FE378 v8::internal::compiler::Operator::EffectOutputCount+248
22: 00007FF6FC84FCAB v8::internal::wasm::WasmCode::safepoint_table_offset+33995
23: 00007FF6FC84241F v8::base::CPU::has_fpu+50495
24: 00007FF6FC851775 v8::internal::wasm::WasmCode::safepoint_table_offset+40853
25: 00007FF6FC9379E7 uv_timer_stop+1207
26: 00007FF6FC933E5B uv_update_time+491
27: 00007FF6FC9339A2 uv_run+1266
28: 00007FF6FC905F95 node::SpinEventLoop+389
29: 00007FF6FC80D3C8 cppgc::internal::Marker::conservative_visitor+51768
30: 00007FF6FC892A4E node::InitializeOncePerProcess+2990
31: 00007FF6FC894D0E node::Start+3566
32: 00007FF6FC893F50 node::Start+48
33: 00007FF6FC69E44C AES_cbc_encrypt+150140
34: 00007FF6FDA013D4 inflateValidate+19028
35: 00007FFCA23A3034 BaseThreadInitThunk+20
36: 00007FFCA4E71551 RtlUserThreadStart+33`
How to create the image gallery with N number of images to show to user to select in the app form in react js app ? So ,once user click’s the ‘open gallery button’ in the app form, user can view the image gallery to select one and upload in the app.(like wtsup emoji’s gallery)(we need to store all the gallery images inside the app itself)