【发布时间】:2020-04-26 10:51:13
【问题描述】:
尝试使用 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
【问题讨论】:
-
如果你在你的shell中做
env-cmd,它是否被定义了?似乎它没有正确添加到您的 PATH -
我该如何解决这个问题?有什么参考吗? @QuantumLicht
-
以下是遇到相同问题的其他人的解决方案:stackoverflow.com/a/56367980
-
否 @ksav 我已经用解决我问题的解决方案更新了我的问题。
标签: node.js npm environment-variables gatsby