Setting up a big commerce stencil environment - development-environment

I am using a mac and have been following the instruction on how to set up a Big commerce stencil development environment posted here:
https://stencil.bigcommerce.com/docs/prerequisites
When trying to launch stencil:
stencil start
in the template directory called "airflow" - see screenshot for the directory structure - I receive:
-bash: stencil: command not found
directory structure
I have been trough the trouble shooting pages
and verified I have the correct versions of npm, node and nvm
npm -v
2.14.20
node -v
v4.4.0
I have also confirmed there is only one version of node installed:
ls ~/.nvm/versions/node
v4.4.0
Is there any advice anyone can give on how to troubleshoot this?
Many Thanks

Are you sure you installed stencil-cli globally? Run npm ls -g --depth=0 and confirm that #bigcommerce/stencil-cli is listed. If not, install it with the -g flag...ie: npm install -g #bigcommerce/stencil-cli
Second, make sure you're running the stencil commands in the directory that contains the .stencil file...in your screenshot that'd be the "stencil" directory inside of "airflow".
Hope this helps!

Related

Environment variables (zsh terminal) installed through npm on MacOS 12.4 Monterey - SOLVED

Background:
Dear Stackoverflow community. I recently switched from Windows to MacOS and am at a loss how to configure environment variables. Many of the previous questions asked here are about bash instead of zsh.
Goal:
I am trying to install an npm package globally. For instance:
npm install -g vercel
or any other package, and use it in my Visual Studio Code terminal (also zsh). If I want to deploy code I have to use 'npx vercel deploy' every time. I want to be able to use "vercel deploy" but instead I get:
zsh: command not found: vercel
What I tried so far:
Installing the package in zsh and visual studio code terminals (didn't work)
Setting the path equal on both VS and terminal: export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I learned that you need to add environment variabels to a .zshrc file. I don't seem to have a zshrc file. When I do:
sudo ~/.zshrc
Password: XXXXXX
sudo: /Users/vincent/.zshrc: command not found
I am getting another error.
I read in the zsh man file that you should use $HOME/.zshrc instead. Again I am getting the same errors:
vincent#Vincents-MacBook-Air-2 ~ % $HOME/.zshrc
zsh: permission denied: /Users/vincent/.zshrc
vincent#Vincents-MacBook-Air-2 ~ % sudo $HOME/.zshrc
sudo: /Users/vincent/.zshrc: command not found
Update 1:
#slebetman Thank you for your explanation. When I open the terminal I go to home via "cd $HOME" which puts me in in the home directory. However there is no way for me to create a .zshrc file in that directory. Neither via touch or vs code. I am getting the following error: "Unable to write file '/home/.zshrc' (Unknown (FileSystemError): Error: ENOTSUP: operation not supported on socket, open '/home/.zshrc')"
Update 2:
I did manage to find the .zshrc file in visual studio code under /etc. I hope this will work. I was able to overwrite the file with Sudo and add environment variables to it.
Add this to the file .zshrc file under /etc and force overwrite it:
export vercel=/Users/vincent/.npm-global/bin/vercel
Screenshots below for those who will try in the future:
Image with .zshrc file layout
Final remarks:
I don't understand how it is so difficult to add environment variables on Mac while everything else is so easy.
I have read many different questions on stackoverflow, and I can't seem to solve it. Also since I am a newbie I am not allowed to comment on there so I post here in the hope that anyone can help me :)
Best,
Vincent
Note that when you do:
npx vercel deploy
Npm will execute vercel for you without installing it. It does that by temporarily downloading vercel. If you want to run vercel directly without using npx then simply don't use npx. Install it instead:
npm install -g vercel
The -g flag installs the module globally and if the module has a CLI it will be available globally as well (note that depending on your setup you may need admin/sudo privileges to use the -g flag). Now you can run vercel by simply typing:
vercel deploy
This works in all operating systems supported by node.js and npm. That means you can even do this in Windows. In fact I use npm to distribute my tools in a simple cross-platform way so I don't have to support multiple package managers like chocolatey (Windows), homebrew (Mac OS), deb (Debian based distros), rpm (Redhat based distros) etc. (npm does not require your software to be written in node.js - I have published packages on npm written in tcl and bash).

Npm updates sucessfully, but still shows old version

When I do a npm -v I see that I am still on 5.6.0. And keep getting prompts to do a npm i npm.
But I've done a sudo npm install npm#latest -g and double checked with a npm outdated -g --depth=0 to see that my global npm is at the latest already (6.0.0).
How do I resolve this conflict? Is the npm I'm using the latest or is it still the old one? Is it because my global is linked incorrectly or something?
Try closing the Terminal - once you open it again it should work, worked for me well.
*IvanD wrote this solution in a comment to the original post, I thought it's worth an answer post.
I can 100% vouch this works.
I got this from someone who teaches node.js.
Give NVM (Node Version Manager) a try. Do the commands in the following ordrer:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
command -v nvm
nvm install node
finally confirm that the update was successful
npm -v
Let's do a better solution if all of the mention methods not help you:
You need to install nvm (Node Version Manager)
After that just run:
nvm install 14
list your versions to see is version installed
nvm ls
and you will get list like this:
v10.2.0
v12.18.3
-> v14.10.0
system
default -> 14.10.0 (-> v14.10.0)
node -> stable (-> v14.10.0) (default)
stable -> 14.10 (-> v14.10.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> v12.18.3)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.22.0 (-> N/A)
lts/erbium -> v12.18.3
Switch default version like this:
nvm alias default 14.10.0
And check:
node -v
If print v14.10.0 you are ready to rock, if not:
nvm use 14
and check again.
This need to work like a charm and you will be happy.
Check your /usr/local/lib folder. I had the same problem and a node_modules folder in here. After removing it and rerunning [sudo] npm install npm#latest -g it showed and used the correct version.
sudo npm install -g n
If you want latest stable version
sudo n stable
If you want the latest version
sudo n latest
Then restart computer
I had this issue today with Node installer node-v10.16.0-x64.msi. Even after installing it I got the node version from npm -v as 3.10... and my react app would fail to start :(
It seems that node creates a folder in APPDATA at %AppData%\Roaming\npm
There was an old npm.exe lying there and this was in my Windows Path at user level. The user level Path overrides the system level Path where the new installer had added its path. The user override caused the new npm to not be found. Solution: Shift-Delete %AppData%\Roaming\npm ! :D Remove and reinstall with node-v10.16.0-x64.msi
Now npm -v gives 6.9.0!
If you have tried all the mentioned approach like :-
sudo npm install -g n
sudo n stable
or
sudo npm install npm#latest -g
still npm -v showing you the older version, once try to close your terminal and open a new one and check.
I found this command line that worked for me.
Update from version 12.18 to the latest version 15.2 correctly.
I hope this is useful:
nvm install node --reinstall-packages-from=node
I think your question is replecated and already has an answer.
First, The LTS and current version of NPM is 5.6.0 for both Node 8.11.1 (LTS) and Node 10.0.0 (Latest current version) according to the official documentation.
Otherwise, sudo npm install npm#latest -g should install the latest version NPM globally.
Search for a node_modules folder in your home directory, rename it or delete it, then try again.
First uninstall your installed nodejs from Control Panel\All Control Panel Items\Programs and Features.
Delete nodejs folder from the Program Files (x86) folder.
Now install new version and check it once.
Though this is an old question and the answer might not be relevant but I found myself into such situation many time, sometimes restarting the server is not a solution because other process will get effected. So you need to refresh the terminal without actually restarting the server and for that you may run exec bash and that will certainly help.
I was facing the same error today.Updated npm version does not reflect.
This is how I resolved it.
A lot of post suggested to use the command npm cache clean --f. But, it did not work for me. Hence, I deleted the "npm" and "npm-cache" folders from the location C:\Users\SearchYourUserName\AppData\Roaming
Uninstalled the existing node.
Re-Installed node version v10.x.x. I downloaded the node-v10.22.1-x64.msi file from https://nodejs.org/dist/latest-v10.x/ and installed it.
Then checked the npm version. It had worked.
Actually this could be happening due to mistakes like you installing packages using yarn ex:
// update the version number in package.json then
yarn install
and trying to run scripts using npm like
npm run start
Actually I did this mistake.
So make sure to use either yarn or npm, but not both.
I faced a similar issue. I had node v14.15.4 installed on ubuntu 18, but when i used node -v it showed v11.0.0.
To check all the node versions available on your system using nvm, use
nvm ls
To set the newly installed node version as the default, use
nvm alias default <version>
Then, just close the terminal and open a new terminal to check the node version.
Problem summary
npm -v # 6.xx
npm install npm#latest -g
npm -v # still the same, but should be 7.xx
Solution based on the answer of fypnlp.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
The terminal now wants to configure some ~/.zshrc file which I don't have on my Mac yet. So let’s create it
nano ~/.zshrc
and paste
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Now restart the terminal and run
command -v nvm # should return "nvm"
nvm install node
npm -v # now it’s 7.xx yay!
I have this same symptom but none of the answers helped and I finally found the issue.
It may not be exactly the same as the OP's but I think it is along the same lines. #Kelvin Zhao's solution of un-installing and re-installing worked for him but not for me so this might be useful for others.
My issue ended up being that I use brew and (I can't remember how exactly) but I seem to be have an old version in the brew Celler.
Brew didn't know about it, or couldn't tell me as I do a brew uninstall node and it says its doesn't exist.
When I run node -v or npm -v I get the old versions.
I uninstalled and reinstalled using brew and npm and sudo npm etc didn't do it. it showed the correct versions being installed but node -v still showed the old.
Turns out there is a version in my /usr/local/Celler directory named node#14.
So running brew uninstall node#14 got rid of that and now node -v doesn't work anymore.
Now re-installing node works. brew install node
More info for further details for those interested.
I wanted to find out where I still had node installed so I did echo $PATH as it had to be somewhere in the path else node -v wouldn't be recognised.
Turns out I had /usr/local/opt/node#14 in my path (which linked to /usr/local/Celler/node#14)
That is how I found it.
And now I think I remember how it got there. I'm 90% sure that I did an upgrade of node and brew asked what to do with the old version and I think I said to keep it.
And that was my mistake that lead me here (and where I think OP's situation differs)
In my case, I wanted to use Version 18 and it was showing 16. I'm using homebrew on my mac and the command that worked for me was the following:
brew uninstall node#16
And voila the version that was showing after is 18.
I had issue with VS Code when I did nvm alias in its own terminal, even after ran alias command, the version kept switching back to old version even I open a new terminal within the VS Code. But as stupid as it sounds, close and reopen the vscode for me worked, after I set the version in an independent terminal.

apidocjs not returning anything in response

I have installed 'apidoc' after installing 'npm' and 'node' for my API documentation by the help of following command:
npm install apidoc -g
After installing apidoc globally, I simply ran below command on my project directory (assuming apidoc will consider its default template file):
apidoc
In result no errors and no documentation generated.
Similarly, I have tried:
apidoc -i ~/PROJECTS/jruby/project/webservice/ -o ~/PROJECTS/apidocs/apidoc/ -t ~/PROJECTS/apidocs/mytemplate/
But nothing happens, in that case I had nothing on 'mytemplate' directory.
Can you guys please tell me what I've missed to install/consider? and why nothing is appearing on command execution?
Note: I'm using this for my ruby application, but unable to install its gem as we're running our application on ruby 1.9 and it requires ruby 2.0. I need an independent solution that should works for other projects as well.
Thank you.
I got the solution; copied 'package.json' file from https://github.com/apidoc/apidoc and ran below command for npm
npm install
after getting success install nodejs properly by following steps:
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs
then went to the project directory and ran the following command:
apidoc
after success of above command got html document in doc/ directory inside project. Cheers !

Yeoman can't recognize a generator that was installed globally

I ran sudo npm install -g generator-flask and it was saved. I was able to confirm by running npm list-g.
I then run yo flask. Thinking that this was going to work, I instead get an error message:
Error flask
You don't seem to have a generator with the name flask installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 22 registered generators run yo with the `--help` option.
I do as it tells me by running yo --help and discover that the flask generator is not there.
I try this with sudo npm install -g generator-angular-flask and the problem is recreated with Angular Flask. I'm assuming this is going to happen for all the generators which is why I've titled it as Yeoman not recognizing new npm installs.
Does anyone know why this has happened?
A workaround, but does solve the problem:
npm link generator-angular-flask
(as does just installing the module locally)
Usually it is a $NODE_PATH issue, but rather then guessing, run:
yo doctor
and follow the instructions!
Node path is the issue.
To setup path:
export NODE_PATH=$HOME/.node/lib/node_modules/
In my case node is in HOME directory.
I was having a similar issue. Basically Yeoman was showing No installed generators, even if I fired up yeoman and installed the generator again still no luck to run it.
I typed yo doctor and did the changes it recommends, but still no luck...
I then ran
export NODE_PATH=$HOME/.node/lib/node_modules/
Then I fired up Yeoman and still no luck.
I then decide run yo doctor again and voila! New errors. I then saw the final recommendation by the yo doctor so I decide to run it:
export NODE_PATH=$NODE_PATH:/Users/slickstyles/.npm-global/lib/node_modules
After I type yo and guess what I see? All my installed yeoman generators showing and working marvelously.
You can use:
yo doctor
and you will not something like:
npm root value is not in your NODE_PATH
[Info]
NODE_PATH = /home/action/.node/lib/node_modules/
npm root = /home/action/.parts/lib/node_modules
[Fix] Append the npm root value to your NODE_PATH variable
Add this line to your .bashrc
export NODE_PATH=$NODE_PATH:/home/action/.parts/lib/node_modules
Or run this command
echo "export NODE_PATH=$NODE_PATH:/home/action/.parts/lib/node_modules" >> ~/.bashrc && source ~/.bashrc
and try again:
npm install -g generator-webapp
Check if you have NODE_PATH set. To set it open a terminal and type (assuming you have node under /opt/node/ and use bash shell)
echo "export NODE_PATH=/opt/node:/opt/node/lib/node_modules" >> ~/.bashrc && . ~/.bashrc
Once done, run yo doctor. If all is ok, run yo to see your installed generators.

Urturn API ur: command not found

I am trying to install urturn api and write my own expression for urturn.com
following http://webdoc.github.com/urturn-expression-api/#!guides/start
After:
npm install urturn-toolbelt -g
I am trying to run sandbox with:
ur sandbox
and got error:
-bash: ur: command not found
Please help
P.S. I am on Mac Os
thanks
It is likely your nodeJS npm/bin folder that is not included in your PATH.
Can you check your PATH variable?
Node NPM package bin files are all symlinked in the same ./bin folder. If you installed NodeJS using Homebrew (brew install node), it should be /usr/local/share/npm/bin.
You can echo your current path using:
echo $PATH
If the folder above does not appear in the list, check your .bashrc or .bash_profile files and fix any problem.
A fix that is likely to work is to add the following line in ~/.bash_profile
PATH=$PATH:/usr/local/share/npm/bin