【问题标题】:visual studio code not recognized parcel视觉工作室代码无法识别包裹
【发布时间】:2021-12-29 00:37:41
【问题描述】:

大家好,我是 Parcel 的新手,我正在尝试使用 Parcel 在其上构建我的网站。我安装了包裹使用

npm install --save-dev parcel

但没用。然后我运行 parcel index.html 并返回

parcel : The term 'parcel' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name,  
or if a path was included, verify that the path is correct and try again.  

我尝试卸载包裹并重新安装,但没有成功。任何想法为什么会发生这种情况?先感谢您。 下面是我的 package.json

package.json

 {
      "dependencies": {
        "dat.gui": "^0.7.7",
        "gsap": "^3.6.0",
        "load-asset": "^1.2.0",
        "nice-color-palettes": "^3.0.0",
        "three": "^0.126.1",
        "vec2": "^1.6.1"
      },
      "devDependencies": {
        "glslify-bundle": "^5.1.1",
        "glslify-deps": "^1.3.2",
        "parcel": "^2.0.1",
        "parcel-bundler": "^1.12.5"
      }
    }

【问题讨论】:

    标签: parceljs


    【解决方案1】:

    当您运行npm install --save-dev parcel 时,您正在安装本地 包,这些包仅用于此特定项目,而不是您计算机上的任何地方(请参阅docs)。因此,默认情况下,与这些包关联的命令不会添加到 CLI 的全局路径中。运行本地安装命令的一种方法是将它们放入您的package.json"scripts" 字段:

    {
       ...
       "scripts": {
          "build": "parcel index.html"
       }
    }
    

    当它们在该上下文中运行时,它们将有权访问本地安装的包。

    我注意到您的 package.json 存在另一个问题 - 您同时安装了 parcel-bundler parcel 软件包。 parcel-bundler 是已弃用的 v1 版本的 parcel,当它与 parcel (v2) 软件包并排安装时,它将覆盖您的 scripts 中的 parcel 命令,因此您将获得 v1 v2 的版本,这可能不是您想要的。我建议运行npm uninstall parcel-bundler

    【讨论】:

      猜你喜欢
      • 2020-06-14
      • 2013-10-26
      • 1970-01-01
      • 2018-07-05
      • 2015-07-10
      • 1970-01-01
      • 2011-08-29
      • 2019-01-22
      • 1970-01-01
      相关资源
      最近更新 更多