Understanding the Vue CLI Creation Process
When running vue create project-name, the command doesn't require node as a prefix. This behavior stems from how Node.js packages handle executable scripts.
To use Vue CLI, first install it globally:
npm install -g @vue/cli
# or
yarn global add @vue/cli
After installation, check the CLI version with vue --version. The executable location can be found using:
# Windows
where vue
# Mac/Linux
which vue
The vue command is a symlink pointing to node_modules/@vue/cli/bin/vue.js. This JavaScript file begins with a shebang line:
#!/usr/bin/env node
This directive instructs the system to locatte Node.js in the environment and execute the script with it.
To demonstrate this mechanism, create a test file test.js:
#!/usr/bin/env node
console.log('Hello World');
Create a symlink in Node's root directory:
ln -s /path/to/test.js customcmd
Now customcmd can be executed directly from any location in the terminal.