I cannot run micro in terminal although it is installed global - node.js

I tried https://github.com/zeit/micro
and unable to run npm start
I run micro in terminal and also see the error
I type in terminal "micro"
Response :
/usr/local/lib/node_modules/micro/bin/micro.js:33
let file = args.sub[0]
SyntaxError: Block-scoped declarations ...

The error message looks as if you were using a version of Node.js that is not up-to-date. So, update your installation of Node.js, and everything should be fine.
Just in case you don't do that yet, have a look at the Node Version Manager which makes installing and managing different versions of Node.js a breeze. If you have installed it on your local system, installing the current version of Node.js becomes as easy as:
$ nvm install 7.5.0
(Or whatever the current version of Node.js is when you read this answer.)

Related

npm - The system cannot find the path specified (But then shows the result)

I am using npm after installing nodejs.
I have installed it once before and I just finished deleting all the components because it kept giving the error in the image below, but when I try to use npm, I keep getting errors saying.
The system cannot find the path specified.
Even though I reinstalled node, it still gives these weird errors where it says the error twice on powershell and once on cmd.
I'm so confused :(
In case you are using nvm to manage your node versions. You can just change your node version and it should work. This solution worked for me.
Check the current nvm version by using the command nvm current.
If that is not the version which you currently installed or updated, use the command nvm use <new_version>
for example: nvm use 16.17.0

switching node version in linux for VS Code installation

I'm trying to install VS Code on a Raspberry PI (Pi 3).
I got the Raspberry Pi OS with some pre-installed node application that I want to debug and extend the functionnality.
There for i thought it would be great to have VS Code Server running on the Pi so that i don't have to have the Pi connected to the Internet all the time in order to do the remote-ssh (and this option didn't even work).
The "Blackbox" application that I want to debug / extend the functionnality runs with node v7.10.0.
Or at least that's what node -v tells me.
I've tried to install nvm in order to switch node versions to be able to install VS Code Server.
I've done the nvm install 12.0.0 (as VS Code Server says it requires at least node v12) and the nvm use v12.0.0. I've tried to use nvm alias default v12.0.0 aswell, but still if i type node -v it gives me the v7.10.0. The installation of VS Code server doesn't succeed as it is most probably using the node version installed directly in the linux.
Is there anything i can do in order to have the node -v giving out v12.0.0 so that VS Code can install properly?
VS Code thereafter probably need to use this version (v12.0.0) to operate but the "blackbox" node project still needs to run with node version v7.10.0 (I don't know it it supports anything higher that that).
I thought that nvm is controlling the node versions that and that i would be possible to run two different node versions beside each other or at least switch between them.
Is there anything I can do to install VS Code Server?

How Can Knex (or Any NPM Package) Run a Different Version of Node?

I'm trying to use Knex's seed:run command (ie. npx knex seed:run), and inside my seed file I've added this line, which logs the version of Node that it's being run with:
console.log(process.version);
Now, if I run that exact same line of code in the Node command prompt itself (node), I get:
v14.2.0
Similarly, when I run node --version it correctly returns v14.2.0.
However, when Knex runs my seed file, I instead see:
v11.15.0
Can anyone explain how/why Knex is using a different version of Node, and how I can make it stop?
P.S. I've tried wiping my node_modules folder out and re-installing via npm i, but Knex continues to use an old Node somehow. Knex itself is installed at the latest version (0.21.1).
This may happen if you have a global installation that runs in privileged account (root), and a local installation to current user.
It is possible you are using some node versioning tool to manage nodejs versions, it creates a symbolic link to a managed version of node that overrides the default configuration. There are many tools that does that like nvm, n.
Danizavtz's answer didn't solve thigns for me, but it did point me in the right direction. I realized that I did have two versions of Node: one installed by Linux (using apt-get), and one I'd installed myself (to get a newer version of Node).
The solution for me was to remove the system version of Node with:
sudo apt-get remove node
That left me with a working Node ... but it removed my npm. I guess I could have just re-installed everything, but since I already had node and just needed npm, I downloaded the latest Node installation and used the node in it to install npm. I did this both with and without sudo (I'm not sure if doing it without sudo was even necessary, as it didn't fix things):
sudo ~/node-v14.3.0-linux-x64/bin/node ~/node-v14.3.0-linux-x64/bin/npm i -g npm
After that I finally got the expected Node version when I ran npx/npm!

I installed node.js v5.12.0 but the version showing v0.12.2

I installed Node.js from (https://nodejs.org/dist/latest-v5.x/node-v5.12.0-x64.msi), but the issue is , its showing version v0.12.2 instead of v5.12.0 which is required.
I try to update the node.js 5.2 installer but still showing version v0.12.2.
I have uninstalled Node.js and reinstall node-v5.12.0-x64.msi but still it’s not updated. Due to this am not able to run further commands for Ionic environmental setup.
Open a terminal and type where node
It should point to an old version of node (v0.12.2) still installed on your computer, for example C:\bin\node.
As Node.js is portable, you can have multiple versions on your computer.
If it cannot be uninstalled, simply delete C:\bin\node folder.
Then:
Open Windows System Properties/Advanced system properties
Click on Environment variables and edit PATH variable
Remove inside its value the path of the old version of node (C:\bin\node in our example).
Re-install Node v5.
Close your terminal and open a new one then type where node, it should point to Node.js v5
Most likely, you have an old Node version for x86 platform, and you are installing a newer version for 64 bit. Remove the path to the x86 from the Paths env variable, or move it to after the 64 bit path.
Solution:
List node.js installatios using nvm:
nvm ls
High chance the version you tried to install is also listed
Select the version to use using nvm
nvm use
(Not a direct solution)
You can try to install using nvm
Uninstall nodejs and follow the instruction from https://github.com/coreybutler/nvm-windows

Using phantom on Node webkit

I am trying to scrape dynamic content in Node webkit by using Phantom .
I have added phantomjs to env variable also.
When i run the application i get a version mismatch error:
"Uncaught Error: Module version mismatch. Expected 43, got 46."
By running nw:version i get the following versions:
nw.js v0.12.3
io.js v1.2.0
Chromium 41.0.2272.76
How should i get around this error?
If you were able to implement similar functionality using some other package, let me know.
Native modules (phantom is one of them, my experience was with lwip) must be rebuilt to work inside nw.js; the ones you install with npm are not compatible. It is also recommended to install node.js version matching that which is used by nw.js (i.e. io.js 1.2.0).
The instruction on how to rebuild: https://github.com/nwjs/nw.js/wiki/build-native-modules-with-nw-gyp
Basically, you would
$ npm install -g nw-gyp
$ cd node_modules/phantom
$ nw-gyp configure --target=0.12.3
$ nw-gyp build
Note "0.12.3" version in configure because that's what your nw:version shows.
Also, note different pre-requisites depending on which OS you use: https://github.com/nwjs/nw-gyp
To do web-scraping in nw.js I successfully use the following stack (on Windows 7):
nw.js 0.12.3
phantomjs module with phantomjs 1.9.8 or 2.0.1b
node-phantom-simple module

Resources