cross-env/dist/index.js:42意外令牌} [英] cross-env/dist/index.js:42 unexpected token }

查看:102
本文介绍了cross-env/dist/index.js:42意外令牌}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些背景知识:我正在开发Laravel 5应用程序.我正在使用Homestead(使用Vagrant/VirtualBox)在Windows 7上进行本地开发,并通过CodePipeline部署到Amazon EC2实例.

A little background: I'm developing a Laravel 5 application. I'm developing locally on Windows 7 using Homestead (using Vagrant/VirtualBox) and deploying to an Amazon EC2 instance through CodePipeline.

当试图让Laravel Mix在本地工作时,我一直遇到很多错误,最终导致我找到了在全球范围内安装跨环境的解决方案,而不是将其包含在package.json.code的devDependencies中>.当然,这也意味着我的Amazon部署也需要更新到该设置.除了解释在相关情况下在我的部署中全局安装cross-env之外,所有这些都没有真正的意义.

While trying to get Laravel Mix working locally, I kept running into a cacophony of errors that eventually led me to the solution of installing cross-env globally rather than including it in the devDependencies in package.json. Of course, this also means that my Amazon deployment needed to be updated to that setup as well. None of this is really relevant except to explain that cross-env is installed globally on my deployment, in case that's relevant.

我的 package.json :

{
    "private": true,
    "scripts": {
        ...
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },
    "devDependencies": {
        "axios": "^0.16.2",
        "bootstrap-sass": "^3.3.7",
        "jquery": "^3.1.1",
        "laravel-mix": "^1.0",
        "lodash": "^4.17.4",
        "vue": "^2.1.10"
    }
}

我在 npm run production 上对AWS的部署失败,并出现以下错误:

My deployment to AWS fails on npm run production with the following error:

[stderr]/usr/lib/node_modules/cross-env/dist/index.js:42
[stderr]    });
[stderr]    ^
[stderr]SyntaxError: Unexpected token }

什么可能导致此问题?而我该如何解决呢?我非常怀疑跨环境中是否存在实际上语法错误.

What could be causing this issue? And how can I resolve it? I highly doubt that there's actually a syntax error in cross-env.

推荐答案

我遇到了同样的问题,可以通过更新节点并重新安装npm来解决.

I had the same problem and i could fix it by updating node and re-installing npm.

对我有用的步骤:

使用程序包管理器更新节点:

Update Node using a package manager:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

然后重新安装:

rm -rf node_modules && npm cache clean --force && npm install

希望有帮助

这篇关于cross-env/dist/index.js:42意外令牌}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆