Ubuntu 上的 node_modules(或 npm)有什么问题

What is the problem with node_modules (or npm) on Ubuntu

我去年开始使用 Ubuntu,从今天开始我遇到了非常烦人的问题。首先,问题是 Reactjs 脚本错误,我什至无法启动项目,无论如何我用不同的方式解决了。现在我遇到了问题

  1. 使用 Typescript 项目启动 Reactjs 出现上述错误并且
  2. 正在启动 Vuejs 项目。

我用谷歌搜索问题,但没有任何帮助。我不知道如何永久解决这类问题(我在 Ubuntu more 上没有经验)但我猜这可能是 node_modules 或 npm 文件夹中的错误路径问题。我检查了所有权限,使用 sudo 安装了软件包,我认为这不是权限问题。但是我的文件夹结构看起来很脏,需要清理。如果您想从系统中获得更多信息,我可以提供您想要的一切。我很乐意提供任何帮助!

我的笔记本电脑:HP Pavilion g6,Ubuntu 20.04

React Typescript 项目正在尝试启动

/usr/lib/node_modules/react-scripts/scripts/start.js:19
  throw err;
  ^

Error: Failed to load plugin '@typescript-eslint' declared in 'package.json » eslint-config-react-app#overrides[0]': Cannot find module 'typescript'
Require stack:
- /usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/2.8/node.js
- /usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/2.9/node.js
- /usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/3.0/node.js
- /usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/3.2/node.js
- /usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/node.js
- /usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/index.js
- /usr/lib/node_modules/react-scripts/node_modules/tsutils/index.js
- /usr/lib/node_modules/react-scripts/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js
- /usr/lib/node_modules/react-scripts/node_modules/@typescript-eslint/eslint-plugin/dist/util/index.js
- /usr/lib/node_modules/react-scripts/node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js
- /usr/lib/node_modules/react-scripts/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js
- /usr/lib/node_modules/react-scripts/node_modules/@typescript-eslint/eslint-plugin/dist/index.js
- /usr/lib/node_modules/react-scripts/node_modules/@eslint/eslintrc/lib/config-array-factory.js
- /usr/lib/node_modules/react-scripts/node_modules/@eslint/eslintrc/lib/index.js
- /usr/lib/node_modules/react-scripts/node_modules/eslint/lib/cli-engine/cli-engine.js
- /usr/lib/node_modules/react-scripts/node_modules/eslint/lib/cli-engine/index.js
- /usr/lib/node_modules/react-scripts/node_modules/eslint/lib/api.js
- /usr/lib/node_modules/react-scripts/node_modules/eslint-webpack-plugin/dist/getESLint.js
- /usr/lib/node_modules/react-scripts/node_modules/eslint-webpack-plugin/dist/linter.js
- /usr/lib/node_modules/react-scripts/node_modules/eslint-webpack-plugin/dist/index.js
- /usr/lib/node_modules/react-scripts/node_modules/eslint-webpack-plugin/dist/cjs.js
- /usr/lib/node_modules/react-scripts/config/webpack.config.js
- /usr/lib/node_modules/react-scripts/scripts/start.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/2.8/node.js:3:12)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:997:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/2.8/node.js',
    '/usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/2.9/node.js',
    '/usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/3.0/node.js',
    '/usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/3.2/node.js',
    '/usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/node.js',
    '/usr/lib/node_modules/react-scripts/node_modules/tsutils/typeguard/index.js',
    '/usr/lib/node_modules/react-scripts/node_modules/tsutils/index.js',
    '/usr/lib/node_modules/react-scripts/node_modules/@typescript-eslint/eslint-plugin/dist/util/isTypeReadonly.js',
    '/usr/lib/node_modules/react-scripts/node_modules/@typescript-eslint/eslint-plugin/dist/util/index.js',
    '/usr/lib/node_modules/react-scripts/node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js',
    '/usr/lib/node_modules/react-scripts/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js',
    '/usr/lib/node_modules/react-scripts/node_modules/@typescript-eslint/eslint-plugin/dist/index.js',
    '/usr/lib/node_modules/react-scripts/node_modules/@eslint/eslintrc/lib/config-array-factory.js',
    '/usr/lib/node_modules/react-scripts/node_modules/@eslint/eslintrc/lib/index.js',
    '/usr/lib/node_modules/react-scripts/node_modules/eslint/lib/cli-engine/cli-engine.js',
    '/usr/lib/node_modules/react-scripts/node_modules/eslint/lib/cli-engine/index.js',
    '/usr/lib/node_modules/react-scripts/node_modules/eslint/lib/api.js',
    '/usr/lib/node_modules/react-scripts/node_modules/eslint-webpack-plugin/dist/getESLint.js',
    '/usr/lib/node_modules/react-scripts/node_modules/eslint-webpack-plugin/dist/linter.js',
    '/usr/lib/node_modules/react-scripts/node_modules/eslint-webpack-plugin/dist/index.js',
    '/usr/lib/node_modules/react-scripts/node_modules/eslint-webpack-plugin/dist/cjs.js',
    '/usr/lib/node_modules/react-scripts/config/webpack.config.js',
    '/usr/lib/node_modules/react-scripts/scripts/start.js'
  ]
}
npm ERR! code 1
npm ERR! path /home/ramil/D:/Codes/dev-challanges/todo-app
npm ERR! command failed
npm ERR! command sh -c react-scripts start

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ramil/.npm/_logs/2020-12-29T20_34_08_108Z-debug.log

启动项目时Vuejs项目问题

> myapp@0.1.0 serve
> vue-cli-service serve

node:internal/modules/cjs/loader:928
  throw err;
  ^

Error: Cannot find module '@vue/cli-plugin-babel'
Require stack:
- /usr/lib/node_modules/@vue/cli-service/lib/Service.js
- /usr/lib/node_modules/@vue/cli-service/bin/vue-cli-service.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at idToPlugin (/usr/lib/node_modules/@vue/cli-service/lib/Service.js:145:14)
    at /usr/lib/node_modules/@vue/cli-service/lib/Service.js:184:20
    at Array.map (<anonymous>)
    at Service.resolvePlugins (/usr/lib/node_modules/@vue/cli-service/lib/Service.js:170:10)
    at new Service (/usr/lib/node_modules/@vue/cli-service/lib/Service.js:32:25)
    at Object.<anonymous> (/usr/lib/node_modules/@vue/cli-service/bin/vue-cli-service.js:15:17) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/lib/node_modules/@vue/cli-service/lib/Service.js',
    '/usr/lib/node_modules/@vue/cli-service/bin/vue-cli-service.js'
  ]
}
npm ERR! code 1
npm ERR! path /home/ramil/D:/Codes/Vue-apps/myapp
npm ERR! command failed
npm ERR! command sh -c vue-cli-service serve

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ramil/.npm/_logs/2020-12-29T21_04_13_325Z-debug.log

固定

  1. 将主文件夹 (D:) 的名称从 (D) 更改为 - 我不知道它是否受影响,但删除了符号。

  2. 我添加了 export PATH=$PATH:/usr/bin 到 .bashrc 文件