我正在尝试使用 npm 来处理我在 Homestead 正在进行的项目,但是我遇到了一些错误。 我跑了
npm run watch-poll
但我收到此错误
vagrant@homestead:~/code/testlaravel$ npm run watch-poll
> @ watch-poll /home/vagrant/code/testlaravel
> npm run watch -- --watch-poll
> @ watch /home/vagrant/code/testlaravel
> npm run development -- --watch "--watch-poll"
> @ development /home/vagrant/code/testlaravel
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress
--hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js "--watch" "--watch-poll"
sh: 1: cross-env: not found
npm ERR! file sh
npm ERR! code 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" "--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! /home/vagrant/.npm/_logs/2019-02-18T14_11_57_194Z-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! /home/vagrant/.npm/_logs/2019-02-18T14_11_57_246Z-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! /home/vagrant/.npm/_logs/2019-02-18T14_11_57_290Z-debug.log
我是 npm 的新手,我不知道该怎么做,而且我在网上也没有发现任何人遇到类似的问题。
npm 版本 = 6.7.0
Node 版本 = v10.15.1
如果你需要的话。
我将不胜感激任何帮助,如果您需要有关我正在运行的内容以及如何设置的更多信息,请告诉我。
编辑 1
正在运行
npm install
给出这个结果
vagrant@homestead:~/code/testlaravel$ npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: minimist@1.2.0 (node_modules/fsevents/node_modules/rc/node_modules/minimist):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open '/home/vagrant/code/testlaravel/node_modules/fsevents/node_modules/rc/node_modules/minimist/package.json.3101396508'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
audited 11757 packages in 87.877s
found 2 vulnerabilities (1 low, 1 high)
run `npm audit fix` to fix them, or `npm audit` for details
编辑2
好吧,我跑了
sudo npm i -g cross-env
因为我在没有 sudo 位的情况下遇到了权限错误,而且看起来它有效。
但是我现在收到一个新错误
ERROR Failed to compile with 2 errors 3:18:10 PM
error in ./resources/assets/sass/app.scss
error in ./resources/assets/sass/app.scss
我猜这是我的代码/框架的问题(我正在使用 laravel),但是 sudo npm i -g cross-env
看起来已经修复了它。
最佳答案
您缺少模块跨环境。运行:
npm i -g cross-env
全局安装跨环境。
关于node.js - npm npm run watch-poll 发生 homestead 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54750006/