I am trying to create snowpack config file for my preact application. I have already installed all necessary libraries but it still show an error when I try to run this command snowpack init. error zsh: command not found: snowpack
This is my package.json file
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"author": "EF",
"license": "MIT",
"scripts": {
"start": "snowpack dev --port 3000",
"build": "snowpack build"
},
"devDependencies": {
"@prefresh/snowpack": "^3.1.2",
"snowpack": "^3.8.8"
},
"dependencies": {
"preact": "^10.5.15"
}
}
What could be the problem here?
The problem is that the snowpack binary isn't in your $PATH. The only time it should be is if you globally installed it. But because you haven't, you cannot access it.
There's an easy solution (and the correct way to run binaries) and that is using npx or yarn. Either will do the trick, so whichever you prefer.
npx snowpack ... or yarn snowpack ... from within your project will be able to access the snowpack binary and run it correctly.