如何非全局安装ember-cli 1.13.11?以及nvm配置Node.js v4.0.0后本地安装ember-cli@4.0.0命令无法识别的问题求助
Hey there! Let's break down solutions for both your ember-cli questions clearly:
非全局安装ember-cli 1.13.11的方法
If you don't want to install ember-cli globally and keep it tied to your project, follow these steps:
- First, navigate to your project folder (create one if you haven't yet with
mkdir my-ember-project && cd my-ember-project) - Run the local install command:
Thenpm install ember-cli@1.13.11 --save-dev--save-devflag adds ember-cli to your project'spackage.jsonas a development dependency, making it easy to share or replicate the environment later. - To run ember commands, you can't just type
emberdirectly (since it's not in your system PATH). Instead, use one of these options:- Call the local executable directly:
- On Windows:
.\node_modules\.bin\ember <your-command>(e.g.,.\node_modules\.bin\ember init) - On macOS/Linux:
./node_modules/.bin/ember <your-command>
- On Windows:
- Use npm scripts:
Add a script to yourpackage.json:
Then run commands like"scripts": { "ember": "ember" }npm run ember initornpm run ember serve
- Call the local executable directly:
解决"ember is not recognized"的问题
The error happens because you installed ember-cli locally (without the -g flag), so the ember command isn't registered in your system's PATH. Here's how to fix it, tailored to your nvm setup:
First, confirm the local install worked: Check that there's an ember-cli folder in your project's node_modules, and an ember executable in node_modules/.bin.
Then pick one of these solutions:
- Option 1: Run the local executable directly
In your project folder, run:# Windows .\node_modules\.bin\ember -v # macOS/Linux ./node_modules/.bin/ember -v - Option 2: Use npm scripts (cleanest for project-specific commands)
Add this to yourpackage.json:
Now you can run"scripts": { "ember": "ember" }npm run ember -vto check the version, or any other ember command likenpm run ember build. - Option 3: Install ember-cli globally in your nvm environment
If you want to useemberdirectly from the terminal in this node version, run:
NVM manages global packages per node version, so this will only add thenpm install -g ember-cli@4.0.0embercommand to your current v4.0.0 environment—switching to another node version won't include it unless you install it there too.
内容的提问来源于stack exchange,提问作者Raja R
相关产品推荐
相关产品推荐

