Node version of my program is different than node installation - javascript

I'm getting the following error:
TypeError: fs.copyFile is not a function
The problem is because the function was added to Node in version 8.5. I was running the LTS version when I began this project, but after I realized I needed a newer function I updated my installation of node, but the program still seems to be running an older version. This is an electron program.
When I run
node -v
I get back
v8.8.1
but inside my program, when I run code to check what version I'm running it gives me 7.9.
How can I upgrade my project so it can run a newer version of NodeJS?

Related

Having trouble with node version when running 'npm i'

I am doing a take-home assessment which requires me to 'npm i' a project into vscode and to code a solution. I have downloaded the repo successfully but I keep getting a very extensive error when I try to run 'npm i'.
The instructions say that I should be using Node.js version 14.x. I checked what version of node I have installed and I have node v16.13.1. I assume this should be fine? Or do I need to have the older version 14.x in order to install my dependencies succesfully?
I'm a bit new to coding so hopefully this question makes sense. Thank you!
Hey so from my experience, it can also cause errors if you have a version which is newer than the expected version.
To keep track of your node versions, which you have installed I can recommend:
https://github.com/nvm-sh/nvm
https://github.com/coreybutler/nvm-windows/releases
The first Solution works for linux,mac and wsl, the second is for windows only.

I keep getting builder.rimraf is not a function when i build npm

I am trying to make my svelteapp prodcution ready and therefor running npm run build
I have tried with several adapters but i keep getting the same error saying
> Using #sveltejs/adapter-netlify
> builder.rimraf is not a function
The application itself runs fine with npm run dev.
I have searched everywhere.
tried the following
node version 16.14.0 also tried with older version and the newest 17.5.0
Deleting node_modules and ran npm i again
deleting package-lock.json
tried another adapter like adapter-vercel and adapter-auto that comes with sveltekit
This sounds like you're on an old version of #sveltejs/adapter-netlify that is incompatible with the latest version of SvelteKit. Try running the following to update to the latest versions of everything:
npm i #sveltejs/kit#next
npm i #sveltejs/adapter-netlify#next

You may need an additional loader to handle the result of these loaders in NUXT app and HEROKU platform

I have a NUXT application, hosted on Heroku.
I try to deploy and suddenly I see this issue in the logs which informs me that the build failed.
I have tried to run the build script locally npm run build and it works perfectly.
Why is my code failing in the cloud but run perfectly locally?
If you don't have problems with the npm script that means that the code is fine. Taking a look back I can see that the only thing which is different is the env in which the code runs.
Most of the time the node version which you use locally is different compared with the cloud one and this might bring errors.
Find out your local node version by running node -v in the command line.
After that find out the node version in your cloud provider. In my case is Heroku and the node version is
There is clearly a difference between them.
To have the same node version running in the cloud as well, add the property engines in the package.json file and describe the node version.
This will force Heroku, to run my local version of node.js
By doing so the problem disappeared and the build was successful.

Which nodeJS version does Node Webkit use?

I am new to Node Webkit, so I might not entirely understand how NodeJS and Node Webkit is connected.
I am trying to get the serialport plugin work in Node Webkit. I get this error when trying to require("serialport");:
serialport.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module...
I've tried recompiling and all that - doesn't work. So I would rather just downgrade to a node version that fits. Problem is that if I type node -v in my terminal I get v6.10.1, which according to this should be NODE_MODULE_VERSION 48.
So I am confused when the error tells me that it is using 57. Does Node Webkit use another NodeJS version than the one installed on my computer?
Here are the Node Webkit release notes:
Update Node.js to v8.6.0
https://nwjs.io/blog/v0.25.4/
Node Webkit requires v8.6.0 and you have installed v6.10.1. The serialport module according to this can be used with Node >= v4.x.x. Upgrade node on your local system and try again.
Maybe a npm install is needed? You tried that?

Node.js - Cant run project

im trying to run a node.js example project that i downloaded from here
I downloaded node.js and npm and checked both versions using CMD as seen below.
At first the version of npm wasnt compatible but i followed a youtube guide and now it seems the versions are compatible. If i didnt mention, im using Windows os.
I then installed the socket package by typing in "npm install socket.io#0.9.10 node-static" in cmd and a bunch of writing happened until it finished.
I then open cmd and do, "cd ... then the folders which contain the project" until its the root folder.
I then type in cmd "node app.js" which is the js file contained in the project.
I get this as a result:
The tutorial im following then tells me to go to http://localhost:8080 to see a local copy of the demo but when i do, chrome just loads and loads then after a few minutes says it cant be reached. does anyone know what im doing wrong? any help is appriciated
afaict you're not doing anything wrong, Doesn't work for me either. It was written in 2012 so it's quite possible this worked fine with an older version of Node.JS and older versions of some dependencies. To get it working for me locally I made the following changes:
Change the handler function in app.js to
function handler (request, response) {
fileServer.serve(request, response);
}
And instead of installing an old version of socket.io I installed the latest. You may want to delete your node_modules directory in the project and then:
npm install socket.io node-static

Categories