4

我正在使用 React 16.8.6 和 react-native 0.59.6。IOS。

在输入react-native --version或任何带有react-native前缀的东西时,它显示以下错误。

internal/fs/utils.js:220
    throw err;
    ^

Error: EPERM: operation not permitted, chmod '/usr/local/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/external/xsel'
    at Object.chmodSync (fs.js:1104:3)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/copyToClipBoard.js:50:15)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/middleware/copyToClipBoardMiddleware.js:8:47)
    at Module._compile (internal/modules/cjs/loader.js:956:30) {
  errno: -1,
  syscall: 'chmod',
  code: 'EPERM',
  path: '/usr/local/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/commands/server/external/xsel'
}

我清理了项目。重新启动它。

删除 npm 包并重新安装它。

试过npm install -g react-native-cli

我在 package.lock.json 依赖项中有react-native-community/cli 版本 1.12.0

我不知道该怎么做。我无法链接任何需要 react-native 关键字的库和其他东西。

此外,如果我像sudo react-native --version一样使用 sudo 运行它,它会给出如下所述的。

warn Your project is using deprecated "rnpm" config that will stop working from next release. Please use a "react-native.config.js" file to configure the React Native CLI. Migration guide: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - react-native-google-signin: https://github.com/react-native-community/react-native-google-signin
  - react-native-video: https://github.com/react-native-community/react-native-video#readme
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
3.0.4

请就相同的问题提出一些指导。

谢谢。

4

3 回答 3

3

rm -rf node_modules && npm install这将解决您的问题。

这是因为依赖包的兼容性问题。尝试从目录中移动/删除 package-lock.json 并再次进行安装。

于 2020-02-16T05:55:03.847 回答
-1

我遇到过同样的问题。再次删除node_modules并安装它们可以解决问题。

于 2020-01-11T01:21:09.233 回答
-2

从 node_modules 卸载 react-native 模块并重新安装。

sudo npm 卸载 react-native sudo npm install react-native

于 2020-01-29T13:47:11.703 回答