我正在尝试将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
节点版本= 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
似乎可以解决此问题。
答案 0 :(得分:0)
您缺少模块交叉环境。运行:
npm i -g cross-env
要全局安装跨环境。