npm start Pit Avoidance Notes

1、错误Error: ENOSPC: System limit for number of file watchers

Problem scenario: When using react scaffolding to write a case, using the command npm start is unsuccessful

Error Error: ENOSPC: System limit for number of file watchers error.

reason

The file watcher's system generated limit reached the default upper limit

Solution

view limit

cat /proc/sys/fs/inotify/max_user_watch

increase quota

# 临时限额
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p

# 永久限额
echo fs.inotify.max_user_watches = 524288 | sudo tee -a /etc/sysctl.conf 
sudo sysctl -p

2. Error: /etc/sudoers: syntax error near line

>>> /etc/sudoers: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

reason

The sudoers file is wrong, the sudo command cannot be used, and the /etc/sudoers file cannot be opened

Solution

Reopen the sudoers file, restore the file

# 编辑 visudo
visudo

Under Linux, please press Ctrl+X to exit in the editing state, there will be two situations:
- If the file is not modified, exit directly;
- If the file is modified, it will ask whether you need to save the modification. Enter Y to confirm saving, enter N not to save, press Ctrl+C to cancel and return. Enter Y, and you will be prompted to enter the file name you want to save. There is no need to modify the file name and press Enter directly.

3、Error: EACCES: permission denied, mkdir '/usr/local/xxx'

An error is reported when installing the lerna tool

Error log:

$ npm i -g lerna
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/nodejs/lib/node_modules/lerna
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/nodejs/lib/node_modules/lerna'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/nodejs/lib/node_modules/lerna'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/nodejs/lib/node_modules/lerna'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/chengyalin/.npm/_logs/2022-10-28T07_05_28_844Z-debug-0.log

problem causes:

Insufficient permissions

Solution:

# 为全局安装创建一个配置目录
mkdir ~/.npm-global

# 配置 npm 以使用新的目录路径
npm config set prefix '~/.npm-global'

# 打开或创建一个 ~/.profile 或者 /etc/profile文件并添加以下行:
export PATH=~/.npm-global/bin:$PATH

# 返回命令行,更新系统变量
source ~/.profile
source /etc/profile

# 在不使用 sudo 的情况下全局下载一个包。
npm i -g lerna

Successful installation 

 

Guess you like

Origin blog.csdn.net/bulucc/article/details/127384375