我正在關注Sails文檔並嘗試運行摩卡測試。 我按照文檔指定的方式編輯了我的package.json
,但由於某種原因,當我嘗試運行Mocha時,我總是得到EACESS,權限被拒絕,錯誤。未能通過航行運行摩卡測試
起初我:
Error: EACCES, permission denied '/Library/Application Support/Apple/ParentalControls/Users'
我不明白爲什麼會與運行我的測試做任何事情,倒是對這個文件夾所需的權限。
後來我:
Error: EACCES, permission denied '/Library/Application Support/ApplePushService'
同樣,不明白,這麼改權限此文件夾,這也沒幫上。
我不明白爲什麼摩卡需要這些文件的權限,或者如何解決這個問題。
我跑的命令:
mocha test/bootstrap.test.js test/unit/**/*.test.js
我的項目結構是完全一樣的帆教程。
我正在使用[email protected]。 我的同事克隆回購,並試圖在他的機器上運行測試,但失敗的錯誤完全相同。
我試圖降級到[email protected]這也沒有幫助。
完整的錯誤跟蹤:
events.js:85
throw er; // Unhandled 'error' event
^
Error: EACCES, permission denied '/Library/Application Support/ApplePushService'
at Error (native)
at Object.fs.readdirSync (fs.js:761:18)
at Glob._readdir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:609:20)
at Glob._process (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:393:15)
at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:427:14)
at Array.forEach (native)
at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:426:9)
at Glob._afterReaddir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:635:15)
at Glob._readdir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:613:17)
at Glob._process (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:393:15)
at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:427:14)
at Array.forEach (native)
at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:426:9)
at Glob._afterReaddir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:635:15)
at Glob._readdir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:613:17)
at Glob._process (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:393:15)
at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:427:14)
at Array.forEach (native)
at Glob.<anonymous> (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:426:9)
at Glob._afterReaddir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:635:15)
at Glob._readdir (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:613:17)
at Glob._process (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:393:15)
at Glob.iterator (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:171:10)
at Array.forEach (native)
at new Glob (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:169:22)
at glob (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:57:11)
at Function.globSync (/usr/local/lib/node_modules/mocha/node_modules/glob/glob.js:76:10)
at Object.lookupFiles (/usr/local/lib/node_modules/mocha/lib/utils.js:590:20)
at /usr/local/lib/node_modules/mocha/bin/_mocha:320:30
at Array.forEach (native)
at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:319:6)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
npm ERR! Test failed. See above for more details.
什麼'LS測試/單位/ **/* .test.js'呢?看起來像'/ Library/Application Support /'可能在'test /'目錄的某個地方存在一個符號鏈接。 – robertklep
運行'ls'命令返回:'test/unit/controllers/UserController.test.js test/unit/models/User.test.js'這是我的兩個測試文件。搜索時沒有看到任何符號鏈接。 – OmriToptix
也許這是你的特定目錄的問題?嘗試運行'npm cache clean'然後再次運行'npm install'並再次運行該命令並查看它是否可用。如果沒有,也許嘗試切換dirs? –