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

问题

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

laravel使用npm构建报错laravel-mix/src/Mix.js:18 static _primary = null_第1张图片

> 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

原文链接:https://www.wjcms.net/archive...

你可能感兴趣的:(php)