使用 npm run watch-poll 后报错

1. 运行环境

LNMP开发环境

1). 当前使用的 Laravel 版本?

8.78.1

2). 当前使用的 php/php-fpm 版本?

PHP 版本:7.3.32

php-fpm 版本:7.3.32

3). 当前系统

Linuxmint 20.3Mate(基于Ubuntu20.4)

4). 业务环境

开发环境,无负载均衡

5). 相关软件版本

Nginx1.20.2
MySQL5.6
PHP7.3.32
Redis6.2.6

2. 问题描述?

使用 npm run watch-poll 后报错

> @ watch-poll /www/wwwroot/weibo
> npm run watch -- --watch-poll


> @ watch /www/wwwroot/weibo
> npm run development -- --watch "--watch-poll"


> @ development /www/wwwroot/weibo
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js "--watch" "--watch-poll"

sh: cross-env:未找到命令
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js "--watch" "--watch-poll"`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the @ development 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!     /root/.npm/_logs/2022-01-13T12_38_34_969Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch: `npm run development -- --watch "--watch-poll"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ watch 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!     /root/.npm/_logs/2022-01-13T12_38_34_987Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch-poll: `npm run watch -- --watch-poll`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @ watch-poll 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!     /root/.npm/_logs/2022-01-13T12_38_35_004Z-debug.log

3. 您期望得到的结果?

能正常编译css文件

4. 您实际得到的结果?

报错如上,以下内容是debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'watch-poll' ]
2 info using npm@6.14.4
3 info using node@v10.19.0
4 verbose run-script [ 'prewatch-poll', 'watch-poll', 'postwatch-poll' ]
5 info lifecycle @~prewatch-poll: @
6 info lifecycle @~watch-poll: @
7 verbose lifecycle @~watch-poll: unsafe-perm in lifecycle true
8 verbose lifecycle @~watch-poll: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/www/wwwroot/weibo/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle @~watch-poll: CWD: /www/wwwroot/weibo
10 silly lifecycle @~watch-poll: Args: [ '-c', 'npm run watch -- --watch-poll' ]
11 silly lifecycle @~watch-poll: Returned: code: 1  signal: null
12 info lifecycle @~watch-poll: Failed to exec watch-poll script
13 verbose stack Error: @ watch-poll: `npm run watch -- --watch-poll`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid @
15 verbose cwd /www/wwwroot/weibo
16 verbose Linux 5.4.0-94-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "watch-poll"
18 verbose node v10.19.0
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error @ watch-poll: `npm run watch -- --watch-poll`
22 error Exit status 1
23 error Failed at the @ watch-poll script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

如不能正常显示log,麻烦看图

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
最佳答案

删除 package.json 下的 4 处 cross-env,如图所示,

file

跳过它即可。

2年前 评论
Jiebaobao (楼主) 2年前
讨论数量: 3

第四章已经按教程走完了,但是后边合并分支时出错与文中不同,好在回滚后正常合并提交了,但是 npm run watch-poll 命令还是没有恢复正常,第一次合并前(回滚前)是正常的

2年前 评论

删除 package.json 下的 4 处 cross-env,如图所示,

file

跳过它即可。

2年前 评论
Jiebaobao (楼主) 2年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!