为了账号安全,请及时绑定邮箱和手机立即绑定

laravel使用npm构建报错laravel-mix/src/Mix.js:18 static _primary = null

标签:
laravel

问题

今天在使用npm构建laravel8项目时出现报错:
laravel使用npm构建报错laravel-mix/src/Mix.js:18 static _primary = null

> mix watch -- --watch-options-poll=1000

[webpack-cli] /www/wwwroot/xxx/node_modules/laravel-mix/src/Mix.js:18
    static _primary = null;
                    ^

SyntaxError: Unexpected token =
    at new Script (vm.js:83:7)
    at NativeCompileCache._moduleCompile (/www/wwwroot/xxx/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/www/wwwroot/xxx/node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (/www/wwwroot/xxx/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at module.exports (/www/wwwroot/xxx/node_modules/laravel-mix/setup/webpack.config.js:2:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ watch-poll: `mix watch -- --watch-options-poll=1000`
npm ERR! Exit status 2
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!     /root/.npm/_logs/2021-01-21T09_04_30_514Z-debug.log

方法

于是上网查了很多资料,很多都是说,删除node_modules重装,或者更换taobao镜像,但是试了都不好使,
最后自己摸索,发现是node版本问题,于是,解决这里的问题只需要升级node版本即可

使用命令:(后两条命令选择一条即可)

# 安装n依赖包
npm install -g n
# 安装最新稳定版(推荐)
n stable
# 安装最新版
n latest
点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消