我正在学习edx上的nodejs,遇到了以下问题。如果在package.json中添加了命令,则可以通过npm start运行express应用程序(或其他应用程序
{
"name": "express-hello-world",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": ".\\node_modules\\.bin\\node-dev server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.16.2",
"node-dev": "3.1.3"
}
}在这里,我使用了带有反斜杠的路径的windows样式。但是,如果我想在不同的平台上部署包,该怎么办?我必须指定多个路径吗?因为我不能在json文件中运行像path.join这样的东西,对吗?
以一种(至少)在W10、Linux、MacOS上运行的方式指定此路径的最佳方式是什么?
发布于 2018-02-13 20:24:07
脚本中的二进制文件将由npm在内部解析,因此您可以:
"scripts": {
"start": "node-dev server.js"
},即使它不是全局安装的,它也应该可以工作
它在documentation here中提到过
https://stackoverflow.com/questions/48766688
复制相似问题