简体   繁体   English

Zsh:找不到命令:snowpack

[英]Zsh: command not found: snowpack

I am trying to create snowpack config file for my preact application.我正在尝试为我的 preact 应用程序创建 snowpack 配置文件。 I have already installed all necessary libraries but it still show an error when I try to run this command snowpack init .我已经安装了所有必要的库,但是当我尝试运行这个命令snowpack init时它仍然显示错误。 error zsh: command not found: snowpack错误zsh: command not found: snowpack

This is my package.json file这是我的 package.json 文件

{
  "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 .问题是 snowpack 二进制文件不在您的$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 .有一个简单的解决方案(以及运行二进制文件的正确方法),那就是使用npxyarn 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.项目中的npx snowpack...yarn snowpack...将能够访问 snowpack 二进制文件并正确运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM