共计 1471 个字符,预计需要花费 4 分钟才能阅读完成。
问题
明天在应用 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
原文链接:https://www.wjcms.net/archive…
正文完