Home > Blockchain >  "No version is set for command npm" .tool-versions file missing
"No version is set for command npm" .tool-versions file missing

Time:12-30

I'm attempting to create my react app in VS code. After installing node.js (V 18.12.1), I ran the code to create my app and recieved the following response:

npm create-react-app example

No version is set for command npm Consider adding one of the following versions in your config file at nodejs 16.15.0 nodejs 16.17.0 nodejs 16.17.1 nodejs 16.18.0 nodejs 16.18.1

I attempted the reinstall node.js and believe the issue may be due to the absence of my .tools-version file, but I don't know how to create it.

CodePudding user response:

You can use this

npx create-react-app example

Can see the detail in official document.

CodePudding user response:

This could be because you are using a version of Node.js that does not include the npm command. In this case, you can try installing the npm command by running the following command:

npm install -g npm

or try these.

  1. Verify that Node.js is installed correctly on your system by running the node -v command in a terminal. This should print the version number of Node.js if it is installed correctly.
  2. Check if the npm command is in your system's PATH by running the which npm command in a terminal. This should print the full path to the npm executable if it is in your PATH.
  3. If npm is not in your PATH, you can add it by modifying your PATH environment variable. You can do this by modifying your shell's profile file (e.g., ~/.bashrc, ~/.bash_profile, etc.), or by adding the path to the npm executable to your PATH manually.
  4. If you have multiple versions of Node.js or npm installed on your system, you may need to update your PATH to point to the correct version. Alternatively, you can use a version manager such as nvm (Node Version Manager) to manage multiple versions of Node.js and npm on your system.

Try out and see!

  • Related