node.js - npm start 错误并带有 ERR!代码 ENOENT,系统调用打开

标签 node.js reactjs npm npm-start

我的 React 应用程序中的“npm start”突然出现问题。当我触发它时,这就是我收到的:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /mnt/c/Users/pal/Desktop/dev/myApp/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/palnic/.npm/_logs/2020-02-20T11_30_39_463Z-debug.log

这是 debug.log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
2 info using npm@6.13.7
3 info using node@v12.13.1
4 verbose stack Error: ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
5 verbose cwd /mnt/c/Users/pal/Desktop/dev/myApp/package.json
6 verbose Linux 4.4.0-18362-Microsoft
7 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
8 verbose node v12.13.1
9 verbose npm  v6.13.7
10 error code ENOENT
11 error syscall open
12 error path /mnt/c/Users/pal/Desktop/dev/myApp/package.json
13 error errno -2
14 error enoent ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
15 error enoent This is related to npm not being able to find a file.
16 verbose exit [ -2, true ]

我尝试了以下解决方案:
sudo npm install -g npm     //(ok!)
sudo npm cache clean   //(not working if not using --force flag)

然后 npm install返回:
npm WARN saveError ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/mnt/c/Users/pal/Desktop/dev/myApp/package.json'
npm WARN myApp No description
npm WARN myApp No repository field.
npm WARN myApp No README data
npm WARN myApp No license field.

up to date in 0.454s
found 0 vulnerabilities

我的 npm 版本是: 6.13.7

这是我的 package.json
{
  "name": "myApp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.4.0",
    "@testing-library/user-event": "^7.2.1",
    "firebase": "^7.7.0",
    "node-sass": "^4.13.1",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-redux": "^7.1.3",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.3.0",
    "react-stripe-checkout": "^2.6.3",
    "redux": "^4.0.5",
    "redux-logger": "^3.0.6",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.1.3",
    "redux-thunk": "^2.3.0",
    "reselect": "^4.0.0",
    "styled-components": "^5.0.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

A您对可能的原因和可能的解决方案有什么想法吗?

最佳答案

只需 CD 到 package.json 所在的应用程序目录并运行 npm start再次。

关于node.js - npm start 错误并带有 ERR!代码 ENOENT,系统调用打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60319237/

相关文章:

node.js - 在 Windows 中找不到本地安装的模块

node.js - jsonwebtoken 未在 Nodejs Express 中解码 jwt

node.js - 服务器之间的 websocket 通信

javascript - 将表单 onSubmit 委托(delegate)给 Flux Actions 的集中函数

javascript - 我正在尝试获取我的 json 站点以启用 API,但出现错误 "Unexpected token < in JSON at position 0"

javascript - 使用后端数据渲染页面以在 next.js 中的 getInitialProps 中使用

javascript - 仅在 Travis CI 上使用 Spread 运算符构建失败

javascript - 你能在 Electron 中使用绝对路径吗?

node.js - express 未在 express 中定义

node.js - Netlify NodeJS 函数始终返回 'Response to preflight request doesn' t pass'