简体   繁体   English

在Laravel 5.4和Node.js上使用Laravel Mix Error编译资产

[英]Compile assets with Laravel Mix Error on Laravel 5.4 and Node.js

To make npm globally I ran in the CLI: export PATH=/opt/plesk/node/7/bin:$PATH on Ubuntu (I have Plesk installed). 为了使npm全局生效,我在CLI中运行export PATH=/opt/plesk/node/7/bin:$PATH在Ubuntu上export PATH=/opt/plesk/node/7/bin:$PATH (我安装了Plesk)。

Without not much knowledge I ran npm run watch in the application path but I got several errors: 在没有太多知识的情况下,我在应用程序路径中npm run watchnpm run watch ,但是遇到了一些错误:

user@server:~/avisos.pagina$ npm run watch user @ server:〜/ avisos.pagina $ npm运行监视

@ watch /var/www/vhosts/pagina/avisos.pagina cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js @ watch /var/www/vhosts/pagina/avisos.pagina cross-env NODE_ENV =开发node_modules / webpack / bin / webpack.js --watch --progress --hide-modules --config = node_modules / laravel-mix /设置/ webpack.config.js

sh: 1: cross-env: not found sh:1:跨环境:找不到

npm ERR! npm ERR! Linux 4.9.36-x86_64-linode85 Linux 4.9.36-x86_64-linode85

npm ERR! npm ERR! argv "/opt/plesk/node/7/bin/node" "/opt/plesk/node/7/bin/npm" "run" "watch" argv“ / opt / plesk / node / 7 / bin / node”“ / opt / plesk / node / 7 / bin / npm”“运行”“监视”

npm ERR! npm ERR! node v7.4.0 节点v7.4.0

npm ERR! npm ERR! npm v4.0.5 npm v4.0.5

npm ERR! npm ERR! file sh 文件sh

npm ERR! npm ERR! code ELIFECYCLE 代码ELIFECYCLE

npm ERR! npm ERR! errno ENOENT errno ENOENT

npm ERR! npm ERR! syscall spawn syscall产生

npm ERR! npm ERR! @ watch: cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js @ watch: cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

npm ERR! npm ERR! spawn ENOENT 产生ENOENT

npm ERR! npm ERR!

npm ERR! npm ERR! Failed at the @ watch script 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'. 在@ watch脚本'cross-env NODE_ENV = development node_modules / webpack / bin / webpack.js --watch --progress --hide-modules --config = node_modules / laravel-mix / setup / webpack.config.js失败”。

npm ERR! npm ERR! Make sure you have the latest version of node.js and npm installed. 确保已安装最新版本的node.js和npm。

npm ERR! npm ERR! If you do, this is most likely a problem with the package, 如果您这样做,则很可能是该软件包存在问题,

npm ERR! npm ERR! not with npm itself. 不与npm本身。

npm ERR! npm ERR! Tell the author that this fails on your system: 告诉作者这在您的系统上失败:

npm ERR! npm ERR! cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js 交叉环境NODE_ENV =开发node_modules / webpack / bin / webpack.js --watch --progress --hide-modules --config = node_modules / laravel-mix / setup / webpack.config.js

npm ERR! npm ERR! You can get information on how to open an issue for this project with: 您可以通过以下方式获取有关如何为此项目打开问题的信息:

npm ERR! npm ERR! npm bugs npm错误

npm ERR! npm ERR! Or if that isn't available, you can get their info via: 或者,如果不可用,则可以通过以下方式获取其信息:

npm ERR! npm ERR! npm owner ls npm所有者ls

npm ERR! npm ERR! There is likely additional logging output above. 上面可能还有其他日志记录输出。

npm ERR! npm ERR! Please include the following file with any support request: 请在任何支持请求中包括以下文件:

npm ERR! npm ERR! /var/www/vhosts/pagina/avisos.pagina/npm-debug.log /var/www/vhosts/pagina/avisos.pagina/npm-debug.log

When I read /var/www/vhosts/pagina/avisos.pagina/npm-debug.log this is what I see: 当我阅读/var/www/vhosts/pagina/avisos.pagina/npm-debug.log这就是我看到的内容:

0 info it worked if it ends with ok 0信息,如果一切正常就可以了

1 verbose cli [ '/opt/plesk/node/7/bin/node', 1个详细的cli ['/ opt / plesk / node / 7 / bin / node',

1 verbose cli '/opt/plesk/node/7/bin/npm', 1个详细的cli'/ opt / plesk / node / 7 / bin / npm',

1 verbose cli 'bugs' ] 1详细的cli'bugs']

2 info using npm@4.0.5 2信息使用npm@4.0.5

3 info using node@v7.4.0 3使用node@v7.4.0的信息

4 silly fetchPackageMetaData . 4愚蠢的fetchPackageMetaData。

5 silly fetchDirectoryPackageData . 5愚蠢的fetchDirectoryPackageData。

6 silly bugs url https://www.npmjs.org/package/ 6个愚蠢的错误网址https://www.npmjs.org/package/

7 verbose stack Error: spawn xdg-open ENOENT 7详细堆栈错误:生成xdg-open ENOENT

7 verbose stack at exports._errnoException (util.js:1022:11) 出口处有7个详细堆栈._errnoException(util.js:1022:11)

7 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32) Process.ChildProcess._handle.onexit上的7个详细堆栈(internal / child_process.js:193:32)

7 verbose stack at onErrorNT (internal/child_process.js:359:16) onErrorNT上的7个详细堆栈(internal / child_process.js:359:16)

7 verbose stack at _combinedTickCallback (internal/process/next_tick.js:74:11) _combinedTickCallback的7个详细堆栈(内部/进程/next_tick.js:74:11)

7 verbose stack at process._tickCallback (internal/process/next_tick.js:98:9) process._tickCallback处的7个详细堆栈(内部/进程/next_tick.js:98:9)

8 verbose cwd /var/www/vhosts/pagina/avisos.pagina 8详细的CWD /var/www/vhosts/pagina/avisos.pagina

9 error Linux 4.9.36-x86_64-linode85 9错误Linux 4.9.36-x86_64-linode85

10 error argv "/opt/plesk/node/7/bin/node" "/opt/plesk/node/7/bin/npm" "bugs" 10错误argv“ / opt / plesk / node / 7 / bin / node”“ / opt / plesk / node / 7 / bin / npm”“错误”

11 error node v7.4.0 11个错误节点v7.4.0

12 error npm v4.0.5 12错误npm v4.0.5

13 error path xdg-open 13错误路径xdg-open

14 error code ENOENT 14错误代码ENOENT

15 error errno ENOENT 15错误errno ENOENT

16 error syscall spawn xdg-open 16错误的syscall生成xdg-open

17 error enoent spawn xdg-open ENOENT 17错误enoent spawn xdg-open ENOENT

18 error enoent spawn xdg-open ENOENT 18错误enoent spawn xdg-open ENOENT

18 error enoent This is most likely not a problem with npm itself 18 error entent这很可能不是npm本身的问题

18 error enoent and is related to npm not being able to find a file. 18错误信息,与npm无法找到文件有关。

19 verbose exit [ 1, true ] 19详细出口[1,正确]

And now in my website I can see this instead the Laravel 5.4 website: https://i.imgur.com/Q8Su4K9.png 现在在我的网站上,我可以看到它而不是Laravel 5.4网站: https ://i.imgur.com/Q8Su4K9.png

I've tried to run find /var/www/vhosts/pagina/avisos.pagina --name package.json and is not being found anywhere. 我试图运行find /var/www/vhosts/pagina/avisos.pagina --name package.json ,但在任何地方都找不到。 Any ideas to compile assets with Laravel Mix without crashing the app or how to make this work? 有什么想法可以在不使应用程序崩溃的情况下使用Laravel Mix编译资产,或如何使其工作? Thanks in advance! 提前致谢!

Since you're running Ubuntu, odds are good the cross-env part of the command is tripping up your NPM. 由于您正在运行Ubuntu,因此命令的cross-env部分可能会触发NPM。 I've run into this issue numerous times and found removing cross-env (which, IIRC, is a fix/workaround for Windows boxes, so if you're not running Windows anywhere, it's not necessary) to fix it. 我已经无数次遇到此问题,并发现删除cross-env (IIRC是Windows盒的修复/解决方法,因此,如果您不在任何地方运行Windows,则没有必要)进行修复。 Alternatively (or if you are running Windows), you should be able to install cross-env with npm install -g cross-env . 或者(如果您运行的是Windows),你应该能够安装cross-envnpm install -g cross-env

I've found it helpful to run the node commands directly when I run into problems, so I get the errors themselves. 我发现遇到问题时直接运行节点命令会很有帮助,因此我会自己得到错误。 In this case: 在这种情况下:

cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

If my suspicion is correct, you'll want to convert it to: 如果我的猜想是正确的,则将其转换为:

NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

Things like npm run watch are simply shortcuts to these longer scripts. 诸如npm run watch之类的东西只是这些较长脚本的快捷方式。 These shortcuts are declared in your package.json file (where you can also define your own script shortcuts if you want). 这些快捷方式在package.json文件中声明(如果需要,您还可以在其中定义自己的脚本快捷方式)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM