【发布时间】:2021-02-25 22:14:14
【问题描述】:
我正在尝试按照Twilio 上的教程使用 Node.js 制作 CLI,在完成 npm link 之后,我在使用该命令时收到此错误。我读了一篇旧的溢出帖子,上面说要将节点添加到我的环境变量中,我有。
这是错误:
& : The term '/node.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\thedi\AppData\Roaming\npm\create-project.ps1:15 char:5
+ & "/node$exe" "$basedir/node_modules/@thedigs/create-project/bin/c ...
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (/node.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
这是我当前的代码:
// bin/create-project
#!/usr/bin/env/node
require = require('esm')(module /*, options */);
require('../src/cli').cli(process.argv);
// src/cli.js
export function cli(args) {
console.log(args);
}
// package.json
{
"name": "@thedigs/create-project",
"version": "1.0.0",
"description": "A CLI to bootstrap my new projects, whatever that means.",
"main": "src/index.js",
"scripts": {
"start": "nodemon ."
},
"publishConfig": {
"access": "public"
},
"bin": {
"@thedigs/create-project": "bin/create-project",
"create-project": "bin/create-project"
},
"keywords": [
"cli",
"create-project"
],
"author": "thedigs",
"license": "ISC",
"dependencies": {
"@types/node": "^14.14.31",
"esm": "^3.2.25",
"nodemon": "^2.0.7"
}
}
我最好的猜测是教程落后于版本,希望你们中的一个可以为我解决这个问题。谢谢!
【问题讨论】:
-
解决方案在下面的空间中作为答案。不要编辑问题以添加解决方案。
-
我也有同样的问题
-
与我的代码比较后,我意识到我们做错了什么。检查出来后添加我的答案是正确的答案。谢谢。
标签: javascript node.js command-line-interface