gpt4 book ai didi

node.js - Gatsby 的环境变量 "env.cmd not found"

转载 作者:行者123 更新时间:2023-12-05 07:15:12 24 4
gpt4 key购买 nike

尝试使用 Gatsby 运行 env.cmd,但我收到 sh: env-cmd not found。我确实已经安装了软件包。我尝试删除 .node-modules 并运行 npm install 但我仍然遇到同样的错误。

gatsby-config.js:

{
...
"scripts": {
"build": "gatsby build",
"develop": "env-cmd --file .env.development --fallback gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"start": "npm run develop",
"serve": "gatsby serve",
"clean": "gatsby clean",
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
},
"dependencies": {
"gatsby": "^2.18.12",
"gatsby-plugin-sass": "^2.1.26",
"node-sass": "^4.13.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"typescript": "^3.7.4"
},
"devDependencies": {
"env-cmd": "^8.0.2",
"prettier": "^1.19.1"
},
...
}

终端:

npm run develop

> gatsby-starter-hello-world@0.1.0 develop /Users/renatognunes/Documents/Studies 1:4/Gatsby/gatsby-site
> env-cmd --file .env.development --fallback gatsby develop

sh: env-cmd: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! gatsby-starter-hello-world@0.1.0 develop: `env-cmd --file .env.development --fallback gatsby develop`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the gatsby-starter-hello-world@0.1.0 develop script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

更新对于遇到相同问题的任何其他人,这是我发现对我有用的解决方案:https://stackoverflow.com/a/56367980/10225590

最佳答案

将我的 npm 版本从 v14.18.3 更改为 v16.3.1 为我解决了这个问题

关于node.js - Gatsby 的环境变量 "env.cmd not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59653699/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com