【问题标题】:code ELIFECYCLE npm local pacakges not working代码 ELIFECYCLE npm 本地包不起作用
【发布时间】:2020-07-12 20:40:33
【问题描述】:
╰─ npm run dev

> nextjspractise@0.1.0 dev /home/auura/D:drive/React/nextjspractise
> next dev

sh: 1: next: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! nextjspractise@0.1.0 dev: `next dev`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the nextjspractise@0.1.0 dev 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!     /home/auura/.npm/_logs/2020-04-01T06_32_26_968Z-debug.log

package.json 文件

{
  "name": "nextjspractise",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "axios": "^0.19.2",
    "next": "9.3.2",
    "react": "^16.13.1",
    "react-dom": "^16.13.1"
  }
}

当我尝试使用 npm run dev 安装 nextjs 包和脚本后,我的本地包无法正常工作,即使 package.json 包含与 node_modules 相同的所有包,然后也找不到包的错误

如果我在全局安装下一个 react react-dom 包,则 npm run dev 命令执行正常,但本地包不起作用

本地包不工作 操作系统:Ubuntu 18.04.4

【问题讨论】:

    标签: node.js ubuntu npm


    【解决方案1】:

    只需执行npm inpm install 然后运行命令npm run dev(对于NextJS)对我来说很有效:)

    【讨论】:

      【解决方案2】:

      更改package.json中的脚本:

      {
        "name": "nextjspractise",
        "version": "0.1.0",
        "private": true,
        "scripts": {
          "dev": "npm dev",
          "build": "npm build",
          "start": "npm start"
        },
        "dependencies": {
          "axios": "^0.19.2",
          "next": "9.3.2",
          "react": "^16.13.1",
          "react-dom": "^16.13.1"
        }
      }
      

      npm 是运行节点应用程序的事实标准。 (yarn也是一种替代品)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-15
        • 2021-01-18
        • 2020-12-02
        • 2011-10-04
        相关资源
        最近更新 更多