I tried to run this command npx create-react-app my-app and got this error
error #typescript-eslint/eslint-plugin#4.5.0: The engine "node" is incompatible with this module. Expected version "^10.12.0 || >=12.0.0". Got "11.13.0"
error Found incompatible module.
The weird thing is I used node version 15.0.1 (latest) and yarn version 1.22.10 (latest) and the version that npx used Got "11.13.0" which does not exist on my machine.
Anybody face this problem ? Please help, many thanks in advance.
The situation may be different on Windows, but on UNIX-like operating systems (including macOS), you can find the path to the node being executed by npx with:
/usr/bin/env node -p process.execPath
This is because the npx file starts with #!/usr/bin/env node. So you can use /usr/bin/env node to execute the same node that npx will.
-p means "print the value" and process.execPath is the path to the executable.
Why do you want to do the above and not just use which node?
which will report aliases, which means that it will report the node executable you will see in your shell. That's not what npx will use, and that seems a likely possibility to explain why npx might use a different Node.js version than you expect.
$ alias node=echo
$ node foo
foo
$ which node
node: aliased to echo
$ /usr/bin/env node -p process.execPath
/Users/trott/.nvm/versions/node/v15.0.1/bin/node
$
Related
I wanted to use mpv option for my Node project, but it seems the option is reserved already.
$ npm --mpv
output : 6.5.0
what's the mpv option pointing?
and is there any way I can use the mpv option for my Node project?
TLDR
You can use --mpv as an argument to your node.js project. There is nothing that would make it not work.
Example:
// example.js
if (process.argv[2] == '--mpv') {
console.log('hooray');
}
The script above would print hooray if you run it with --mpv as argument:
$ node example.js --mpv
hooray
Details:
The npm command treats -- options the same as - options for some reason. Thus the command:
npm --mpv
is somehow interpreted as
npm -m -p -v
Neither m nor p does anything and are ignored instead of throwing errors. But the v option prints out the version number. Thus the command is the same as
npm -v
Note that npm is not node.js. Node does not behave the same and would throw an error:
$ node --mpv
node: bad option: --mpv
Indeed, the npm project explicitly declares themselves to not be a node package manager even though npm is now managed by the node.js project directly. Npm can deploy packages written in other languages such as Ruby (such as the original Sass project, now re-written in js), Python or even C and assembly.
--mpv is not a reserved option -- nor is any other sequence. node itself takes many options, but anything on the command line after your script name is passed directly to process.argv.
In other words, the following have two different behaviors:
$ node --inspect script.js # enables node's built-in debugger; process.argv = ['node', 'script.js']
$ node script.js --inspect # process.argv = ['node', 'script.js', '--inspect']
Also, --mpv does not appear anywhere in the npm documentation. I suspect that the npm CLI is misinterperting --mpv as -v and printing its version number.
I am trying to set up the needed environment for a project I am gonna work on. I am not able to run gulp command as expected (as it is told on the getting started page of Gulp).
I am using Linux (PopOS) which is based on Ubuntu and Debian.
So, I have tried to fix it in the local project repo - which was unsuccessful.
Then I decided to create a new project directory and see whether it works. I have done these in the new project file:
$ node -v
v8.10.0
$ npm -v
5.6.0
$ npx -v
9.7.1
$ npm install --global gulp-cli
$ npm install --save-dev gulp
After all these, at the last step, when I do:
$ gulp
-bash: /usr/bin/gulp: No such file or directory
this is what I get.
However, if I do this,
$ node_modules/gulp/bin/gulp.js --version
CLI version: 2.2.0
Local version: 4.0.2
I get some result.
Does anybody see why gulp isn't getting in my binary directory? - Even though I have done the same exact steps that are presented on the official website?
This issue was about npm prefix that defines the directory where npm packages will be installed. Because the gulp binary wasn't in one of the directories that is in PATH variable bash wasn't able to find it. Here you can find details about how to fix.
I have this post-receive script as a git hook when exporting with the following contents
#!/usr/bin/env bash
export NODE_ENV=production
git --work-tree=/home/myusername/app --git-dir=/home/myusername/git checkout -f
cd /home/myusername/app
npm prune
npm install --production
knex migrate:latest
When ssh'd in my server I installed knex globally but it doesn't seem to exist within the bash shell's environment. I lack the knowledge of knowing how they are different. I also noticed my node versions were different. How do I import my user's normal environment?
To get the names and versions of modules that you have installed globally run:
npm list --global --depth=0
You can then install those modules on the second system with:
npm install --global module_name module_name ...
If you want to install a specific version of Node on the second system you can use nvm or see those answers for details:
Run npm as superuser, it isn't a good idea?
node 5.5.0 already installed but node -v fetches with "v4.2.1" on OS X & homebrew?
Node installed but node cannot be found in Ubuntu VPS
This is the first time I see a shebang like that:
#!/usr/bin/env bash
I've seen using /usr/bin/env to find node, python, perl interpreters etc. but never for bash. Usually it's just:
#!/bin/bash
Remember that if you want to run some program from a Bash script (without giving a full path) then it must be in a directory that is in the PATH environment variable.
To see your PATH run:
echo $PATH
Or you can use a full path to a binary in a script:
#!/bin/sh
/full/path/to/something
and then it doesn't need to be in the PATH.
I'm trying to setup babel on Ubuntu 14.04 but it doesn't seem to be working!
Here are some outputs that may be required:
$ which node
/usr/sbin/node
$ which nodejs
/usr/bin/nodejs
$ which babel
/usr/local/bin/babel
$ which babel-node
/usr/local/bin/babel-node
When I execute babel or babel-node the prompt just returns. The same happens on executing the commands with a filename as argument. (The file has just console.log("hello").
How do I fix this?
The /usr/sbin/node vs /usr/bin/nodejs issue has been covered in Cannot install packages using node package manager in Ubuntu but basically Ubuntu has a separate node package that is NOT Node.js. The package for Node.js on Ubuntu is called nodejs. If you have both installed, it means your scripts will try to run using the other unrelated application. One option is to symlink nodejs to node.
The best solution however would be to use something like nvm to install node for your user without installing it globally. Then you can install and update node versions extremely easily, and your PATH will always reference node properly.
Changing node to nodejs in the first line of /usr/local/bin/babel-node and /usr/local/bin/babel solves it.
This is really confusing me. If I type "node -v" into the command line, there is no response - it just gives me the $ prompt again. Trying to install node with sudo npm install nodejs gives the response nodejs is already the newest version.
How can I debug this to find out what's going on?
nodejs -v solved the problem.
In some linux distributions node executable is mapped into nodejs.
Are you trying to print the node version? If yes then try
$ node --version
Node is by default installed on /usr/bin/ directory on linux OS it means it should run with normal user privilege but node include some tools that required Superuser privilege so ...
Instead running
node -v
run
sudo node -v
hope it will work...keep coding