希望有人可以提供帮助。我第一次尝试从终端更新并启动量角器,但出现了此错误消息。
我使用的命令是
npm run start
我看了一下package.json脚本,这看起来还不错。我错过了什么吗?
npm.json文件
{
"name": "LocatorTraining",
"dependencies": {
"protractor": "^5.4.1"
},
"scripts": {
"webdriver-update": "./node_modules/.bin/webdriver-manager update",
"webdriver-start": "./node_modules/.bin/webdriver-manager start",
"protractor": "./node_modules/.bin/protractor configurations.js",
"start": "npm run webdriver-manager update &&npm run webdriver-manager start"
}
}
来自终端的消息
JohnSmith-MacBook-Air:~ JohnSmith$ npm run start
npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/JohnSmith/.nvm/versions/node/v7.2.0/bin/node" "/Users/xx/.nvm/versions/node/v7.2.0/bin/npm" "run" "start"
npm ERR! node v7.2.0
npm ERR! npm v3.10.9
npm ERR! path /Users/JohnSmith/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/JohnSmith/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/Users/JohnSmith/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /Users/JohnSmith/npm-debug.log
因此,从下面的评论开始,我尝试在项目级别运行npm run start。
我得到了以下答复。
Ran the npm run start from project level> LocatorTraining@ start /Users/JohnSmith/Documents/JSworkspace/LocatorTraining
> npm run webdriver-manager update &&npm run webdriver-manager start
npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/JohnSmith/.nvm/versions/node/v7.2.0/bin/node" "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/npm" "run" "webdriver-manager" "update"
npm ERR! node v7.2.0
npm ERR! npm v3.10.9
npm ERR! missing script: webdriver-manager
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/JohnSmith/Documents/JSworkspace/LocatorTraining/npm-debug.log
npm ERR! Darwin 17.7.0
npm ERR! argv "/Users/JohnSmith/.nvm/versions/node/v7.2.0/bin/node" "/Users/jacquelinegeorge/.nvm/versions/node/v7.2.0/bin/npm" "run" "start"
npm ERR! node v7.2.0
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! LocatorTraining@ start: `npm run webdriver-manager update &&npm run webdriver-manager start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining@ start script 'npm run webdriver-manager update &&npm run webdriver-manager start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the LocatorTraining package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run webdriver-manager update &&npm run webdriver-manager start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs LocatorTraining
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls LocatorTraining
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/JohnSmith/Documents/JSworkspace/LocatorTraining/npm-debug.log
然后我尝试在项目级别访问npm调试日志
/Users/JohnSmith/Documents/JSworkspace/LocatorTraining/npm-debug.log: Permission denied
答案 0 :(得分:1)
(最好将其作为注释,但我还是无法做到)
您在哪个目录中运行npm run start
?似乎您在错误的位置运行了正确的命令。您要确保从项目目录中运行命令。
也就是说,如果您的package.json
文件位于/Users/xx/protractorProj/package.json
,则需要从npm run start
运行/Users/xx/protractorProj
命令。
答案 1 :(得分:1)
浏览脚本
"scripts": {
"webdriver-update": "./node_modules/.bin/webdriver-manager update",
"webdriver-start": "./node_modules/.bin/webdriver-manager start",
"protractor": "./node_modules/.bin/protractor configurations.js",
"start": "npm run webdriver-manager update &&npm run webdriver-manager start"
}
此外,在错误回溯中,您发现:
npm ERR! missing script: webdriver-manager
可用的运行脚本与start中使用的运行脚本不匹配。
开始运行脚本应为:
"start": "npm run webdriver-update && npm run webdriver-start"