我想在我的 Laravel 项目中执行 "npm run watch",但它不能工作。以下是错误信息:
@ watch /Applications/MAMP/htdocs/test-tech/laravel5 npm run development -- --watch
@ development /Applications/MAMP/htdocs/test-tech/laravel5 cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"
sh: cross-env: 命令未找到 npm ERR! 文件 sh npm ERR! 代码 ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR! @ development:
还有调试文件。
我在Google上搜索了一些解决方案,但仍然无法解决。请问如何解决呢?
谢谢。
@ watch /Applications/MAMP/htdocs/test-tech/laravel5 npm run development -- --watch
@ development /Applications/MAMP/htdocs/test-tech/laravel5 cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"
sh: cross-env: 命令未找到 npm ERR! 文件 sh npm ERR! 代码 ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR! @ development:
cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch"
npm ERR! spawn ENOENT
npm ERR!
npm ERR! 在 @ development 脚本中失败。
npm ERR! 这可能不是一个 npm 的问题, 更多日志请参阅上面的输出。
npm WARN 当前 package.json 存在,但 node_modules 目录不存在,请先通过 "npm install" 安装依赖。
npm ERR! 此次运行的完整日志可在下面找到:
npm ERR! /Users/xxx/.npm/_logs/2019-03-29T11_19_55_390Z-debug.log
npm ERR! 代码 ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch: npm run development -- --watch
npm ERR! 退出码 1
npm ERR!
npm ERR! 在 @ watch 脚本中失败。
npm ERR! 这可能不是一个 npm 的问题, 更多日志请参阅上面的输出。
npm WARN 当前 package.json 存在,但 node_modules 目录不存在,请先通过 "npm install" 安装依赖。
npm ERR! 此次运行的完整日志可在下面找到:
npm ERR! /Users/xxx/.npm/_logs/2019-03-29T11_19_55_422Z-debug.log还有调试文件。
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'watch' ]
2 info using npm@5.6.0
3 info using node@v8.11.3
4 verbose run-script [ 'prewatch', 'watch', 'postwatch' ]
5 info lifecycle @~prewatch: @
6 info lifecycle @~watch: @
7 verbose lifecycle @~watch: unsafe-perm in lifecycle true
8 verbose lifecycle @~watch: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Applications/MAMP/htdocs/test-tech/laravel5/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
9 verbose lifecycle @~watch: CWD: /Applications/MAMP/htdocs/test-tech/laravel5
10 silly lifecycle @~watch: Args: [ '-c', 'npm run development -- --watch' ]
11 silly lifecycle @~watch: Returned: code: 1 signal: null
12 info lifecycle @~watch: Failed to exec watch script
13 verbose stack Error: @ watch: `npm run development -- --watch`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid @
15 verbose cwd /Applications/MAMP/htdocs/test-tech/laravel5
16 verbose Darwin 18.2.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "watch"
18 verbose node v8.11.3
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ watch: `npm run development -- --watch`
22 error Exit status 1
23 error Failed at the @ watch script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
我在Google上搜索了一些解决方案,但仍然无法解决。请问如何解决呢?
谢谢。