这个问题 Node.js prompt '>' can not show in eshell 解决了使用 node repl 时的问题,但当你从 npm 中调用 node 时,这个解决方法不起作用。
例如,如果我运行以下命令:
如果您有一个包含 "scripts" : { "start" : "node" } 的 package.json 文件。
例如,如果我运行以下命令:
$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sane defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
^[[1G^[[0Jname: (nodo1) ^[[15G
如果您有一个包含 "scripts" : { "start" : "node" } 的 package.json 文件。
$ npm start
npm WARN package.json nodo1@0.0.1 No README.md file found!
> node
^[[1G^[[0J> ^[[3G
我知道可以通过 "start": "env NODE_NO_READLINE=1 node" 来解决这个问题,但在每个地方都写这句话并不是一个好的解决方案。而且,也许其他使用该软件包的用户并不使用emacs,并且需要以其他方式设置环境变量。
我已经尝试了设置npm alias为NODE_NO_READLINE=1,但是结果仍然相同。
alias npm='env NODE_NO_READLINE=1 npm'