Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个基本的 Express 应用程序,其 package.json 看起来像这样
{ "name": "blog", "version": "0.0.1", "dependencies": { "express": "~3.0.0" }, "engines": { "node": "0.9" } }
显然node它本身并不关心这个文件的内容。有没有办法启动一个应用程序以便npm读取它并报告错误?
node
npm
由于 package.json 只是一个 json 文件,您可以轻松加载和解析它,然后将 engine.node 值与process.version并报告错误。
process.version
无需在这里对 npm 做任何事情。