使用Faust.js搭建无头WordPress时,运行npm run wp-dev报错Invalid Argument
问题描述
我按照Faust.js文档用Next.js搭建无头WordPress站点时,卡在了第二步:在全新创建的项目中运行npm run wp-dev命令,出现目录创建失败的错误,提示信息如下:
Error: Could not create directory "/var/www/html/wp-content/B&ce<%#Yl&k0-&2&=BKkTuOo,U%me@Uj$0U&": Invalid argument.
当前环境为Windows 11 + npm 21.4.0,已经尝试过npm 22、21、18、16版本,问题依旧。完整错误信息如下:
$ npm run wp-dev > faust-tutorial@0.1.0 wp-dev > npx @wp-now/wp-now start --blueprint faust-tutorial-blueprint.json Starting the server...... directory: C:\Users\jill\projects\faust-tutorial mode: playground php: 8.0 wp: 6.8.3 (resolved from alias: latest) WordPress 6.8.3 folder already exists. Skipping download. SQLite folder already exists. Skipping download. blueprint steps: 1 Error: Could not create directory "/var/www/html/wp-content/B&ce<%#Yl&k0-&2&=BKkTuOo,U%me@Uj$0U&": Invalid argument. at descriptor.value (C:\Users\jill\AppData\Local\npm-cache\_npx\7c65af5c66ec2a7e\node_modules\@php-wasm\node\index.cjs:72685:17) at installAsset (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:1106:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.installPlugin (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:1157:34) at async o (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9440:30) at async Object.run (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9367:23) at async runBlueprintSteps (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9475:3) at async startWPNow (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-now/wp-now/main.js:739:5) at async startServer (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-now/wp-now/main.js:1003:42) at async Object.handler (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-now/wp-now/main.js:1184:25) { [cause]: [<generic error, no stack>] { name: 'ErrnoError', node: undefined, setErrno: [Function (anonymous)], errno: 28, message: 'FS error' } } Error: Error when executing the blueprint step #0 ({"step":"installPlugin","pluginZipFile":{"resource":"wordpress.org/plugins","slug":"wp-graphql"}}) : Could not create directory "/var/www/html/wp-content/B&ce<%#Yl&k0-&2&=BKkTuOo,U%me@Uj$0U&": Invalid argument. at Object.run (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9370:37) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async runBlueprintSteps (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9475:3) ... 2 lines matching cause stack trace ... at async Object.handler (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-now/wp-now/main.js:1184:25) { [cause]: Error: Could not create directory "/var/www/html/wp-content/B&ce<%#Yl&k0-&2&=BKkTuOo,U%me@Uj$0U&": Invalid argument. at descriptor.value (C:\Users\jill\AppData\Local\npm-cache\_npx\7c65af5c66ec2a7e\node_modules\@php-wasm\node\index.cjs:72685:17) at installAsset (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:1106:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.installPlugin (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:1157:34) at async o (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9440:30) at async Object.run (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9367:23) at async runBlueprintSteps (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9475:3) at async startWPNow (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-now/wp-now/main.js:739:5) at async startServer (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-now/wp-now/main.js:1003:42) at async Object.handler (file:///C:/Users/jill/AppData/Local/npm-cache/_npx/7c65af5c66ec2a7e/node_modules/@wp-now/wp-now/main.js:1184:25) { [cause]: [<generic error, no stack>] { name: 'ErrnoError', node: undefined, setErrno: [Function (anonymous)], errno: 28, message: 'FS error' } } } Failed to start the server: Error when executing the blueprint step #0 ({"step":"installPlugin","pluginZipFile":{"resource":"wordpress.org/plugins","slug":"wp-graphql"}}) : Could not create directory "/var/www/html/wp-content/B&ce<%#Yl&k0-&2&=BKkTuOo,U%me@Uj$0U&": Invalid argument.
排查及解决步骤
1. 清理缓存目录
错误中的目录名包含&、<等HTML转义字符,属于Windows系统禁止的目录名,本质是WP-Now处理插件下载路径时的编码bug。
- 删除项目根目录下的
.wp-now缓存文件夹,重新运行npm run wp-dev - 若无效,执行
npm cache clean --force清理npm全局缓存,再重新执行启动命令
2. 指定WP-Now稳定版本
当前使用的WP-Now版本可能存在Windows环境适配问题,尝试切换到稳定版本:
npx @wp-now/wp-now@0.12.0 start --blueprint faust-tutorial-blueprint.json
也可以直接修改package.json中的wp-dev脚本,将@wp-now/wp-now替换为带版本号的格式。
3. 手动安装WP-GraphQL插件
跳过蓝图自动安装流程,手动搭建WordPress环境:
- 运行
npx @wp-now/wp-now start启动基础WordPress服务 - 访问后台(默认地址为
http://localhost:8888/wp-admin) - 手动搜索安装并激活WP-GraphQL插件
- 继续后续Faust.js配置步骤
4. 检查路径与权限
- 确保项目目录路径无中文、空格或特殊字符(比如
C:\Users\jill\projects\faust-tutorial是合法路径,避免C:\用户\项目\faust教程这类路径) - 以管理员身份运行终端,防止权限不足导致目录创建失败
内容的提问来源于stack exchange,提问作者Jillian Hoenig
相关产品推荐
相关产品推荐

