Shopware 6 开发-模板安装“前端打开失败”

Posted

技术标签:

【中文标题】Shopware 6 开发-模板安装“前端打开失败”【英文标题】:Shopware 6 development-template installation "frontend open as broken" 【发布时间】:2020-01-24 04:17:32 【问题描述】:

我正在 Shopware 6 中创建插件。所以我已经安装了这个问题的“开发模板”参考

Shopware 6 Command './psh.phar administration:build.' is not working

在我打开前端时按照所有安装步骤进行操作后,它坏了,而后端工作正常。 broken front-end(image)

我发现“./psh.phar storefront:build”命令不起作用。它导致如下所示的node.js错误

/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/build/utils.js:116
     catch 
            ^

SyntaxError: Unexpected token 
    at NativeCompileCache._moduleCompile (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:186:36)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/build/webpack.base.config.js:6:15)
    at Module._compile (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/webpack.config.js:23:5)
    at Module._compile (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at WEBPACK_OPTIONS (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/utils/convert-argv.js:116:13)
    at requireConfig (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/utils/convert-argv.js:118:6)
    at /var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/utils/convert-argv.js:125:17
    at Array.forEach (<anonymous>)
    at module.exports (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/utils/convert-argv.js:123:15)
    at yargs.parse (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/cli.js:71:45)
    at Object.parse (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/node_modules/yargs/yargs.js:567:18)
    at /var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/cli.js:49:8
    at Object.<anonymous> (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/cli.js:365:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sw-next-storefront@1.0.0 production: `NODE_ENV=production webpack --config webpack.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sw-next-storefront@1.0.0 production 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/rahul/.npm/_logs/2019-09-24T09_05_58_383Z-debug.log

执行中止,子命令失败!

我认为解决这个问题可以修复前端损坏的错误。

【问题讨论】:

【参考方案1】:

将node和npm更新到最新版本后,它现在可以工作了。我认为错误是nodejs。

【讨论】:

不错的答案!!!尝试在代码中添加一些简短的解释!

以上是关于Shopware 6 开发-模板安装“前端打开失败”的主要内容,如果未能解决你的问题,请参考以下文章

Shopware 5 在模板文件中调用自定义函数

如何在 Shopware 6 中创建可以在 Twig 文件中使用的自定义 Javascript?

Shopware 5 在前端访问控制器变量(模板变量)

shopware 6插件的单元测试未找到自定义服务

php 调试shopware模板属性

Shopware 6:bin/watch-storefront.sh 导致 chrome 出现 CORS 错误