【问题标题】:npm Start and "npm run client" is not working in Nodenpm Start 和“npm run client”在 Node 中不起作用
【发布时间】:2021-01-11 08:01:50
【问题描述】:

我正在尝试运行 Github probyto 中定义的 Node js 程序

我正在按照上面 github 链接中定义的所有步骤进行操作,但是当我尝试运行时

npm run client

它给了我一个错误

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@2.0.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@2.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Gautam\AppData\Roaming\npm-cache\_logs\2021-01-11T07_55_54_943Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mern-jwt-auth@2.0.0 client: `npm start --prefix client`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mern-jwt-auth@2.0.0 client script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Gautam\AppData\Roaming\npm-cache\_logs\2021-01-11T07_55_54_976Z-debug.log

我已经尝试了一些解决方案,例如

更新节点/npm

删除节点模块和 packagelock.json 文件,然后 npm install

npm 更新

但似乎没有任何效果。谁能帮我运行这个。任何帮助表示赞赏

【问题讨论】:

  • 从 package.json 所在的文件夹运行 npm。
  • 我按照你说的从文件夹中运行了“npm”,它似乎工作正常。那如何解决我的错误?
  • 什么意思?您只需从根包文件夹(package.json 所在的位置)运行 npm。
  • 这和 Python 有什么关系?请不要标记垃圾邮件。
  • 您是否在根文件夹中运行了这两个步骤 1. npm run client-install 2.copy config/keys.sample.js config/keys.js 然后根据要求更新 keys.js 文件变量.

标签: node.js npm


【解决方案1】:

他们的 README.md 上的 getting started 页面向您展示了您需要遵循的步骤。

简化:

运行:

npm run client-install

(如果使用 windows)然后运行:

copy config/keys.sample.js config/keys.js

或者如果使用 Mac,运行:

cp config/keys.sample.js config/keys.js

只有这样才能运行开发服务器:

npm run dev

【讨论】:

    【解决方案2】:

    我克隆了 repo 并为您测试了它,它似乎没有任何问题;要使客户端正常工作,您只需执行以下操作:

    npm i; npm run client-install; npm run client
    

    你应该会看到你的 react 应用程序编译成功

    如果由于某种原因,前一个不适合您,您可以在清理 node_modulespackage-lock.json 后重试以下内容(我知道您已经尝试过,但请给出这行代码一个镜头):

    rm -rf node_modules package-lock.json; cd client; rm -rf node_modules package-lock.json; cd ..; npm i; npm run client-install; npm run client
    

    如果仍然无法正常工作,我最后一次尝试是直接从客户端文件夹安装模块,例如:

    cd client; rm -rf node_modules package-lock.json; npm i; npm start
    

    通过这些步骤,它肯定会成功启动并运行,但如果没有,您可能需要进一步调试。

    为此,我特意要检查运行模块安装时是否存在问题,最后检查您是否从正确的注册表下载模块。为此,只需在任何文件夹上运行npm config ls -l,并检查将registry 属性设置为"https://registry.npmjs.org/"

    希望能有所帮助!

    【讨论】:

      【解决方案3】:

      请在客户端文件夹中这样尝试。

      第 1 步:

      npm cache clean --force
      

      第 2 步:

      由于您使用的是 Windows,请手动删除 node_modules 文件夹和 package_lock.json 文件。

      第 3 步:

      npm install
      

      第 4 步:

      npm start
      

      很多人都在使用这种方法来解决像你这样的情况。

      希望这对你有帮助。

      【讨论】:

        【解决方案4】:

        我有同样的问题,我用下面的命令解决了

        sudo npm cache clean -f

        sudo npm install -g n

        sudo n 稳定

        要升级到最新版本(而不是当前稳定版本),您可以使用

        sudo n 最新

        【讨论】:

          【解决方案5】:

          看来,您并没有安装所有需要的软件包。 在项目的文档中有一些你跳过的步骤。 安装软件包后,您需要运行命令来安装其他软件包。

          npm run client-install
          

          在这个运行项目之后:

          npm run client
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2019-08-07
            • 2018-12-23
            • 2021-02-01
            • 1970-01-01
            • 2021-03-11
            • 1970-01-01
            • 2021-07-18
            • 1970-01-01
            相关资源
            最近更新 更多