cli-microsoft365: Not able to run npm run test on fresh Windows install
Hi, I made a fresh Windows 10 install and tried to continue on my contributions for the Office 365 CLI. I followed these instructions step-by-step.
I am able to build and run a linked Office 365 CLI without issues. I took the latest dev branch as basis. Unfortunately, when I try to run npm run test, I receive following output:
@pnp/office365-cli@2.3.0 test C:\Users\PatrickLamber\Documents\GitHub\office365-cli nyc -r=lcov -r=text mocha “dist/**/*.spec.js”
internal/modules/cjs/loader.js:797 throw err; ^
Error: Cannot find module ‘C:\Users\PatrickLamber\Documents\GitHub\office365-cli\node’ at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15) at Function.Module._load (internal/modules/cjs/loader.js:687:27) at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) at internal/main/run_main_module.js:17:11 { code: ‘MODULE_NOT_FOUND’, requireStack: [] } ----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|
All files | 0 | 0 | 0 | 0 | |
---------- | ---------- | ---------- | ---------- | ---------- | ------------------- |
npm ERR! code ELIFECYCLE | |||||
npm ERR! errno 1 | |||||
npm ERR! @pnp/office365-cli@2.3.0 test: nyc -r=lcov -r=text mocha "dist/**/*.spec.js" |
|||||
npm ERR! Exit status 1 | |||||
npm ERR! | |||||
npm ERR! Failed at the @pnp/office365-cli@2.3.0 test script. | |||||
npm ERR! This is probably not a problem with npm. There is likely additional logging output above. |
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\PatrickLamber\AppData\Roaming\npm-cache_logs\2019-11-11T17_25_53_648Z-debug.log
The log is outputting this information:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli ‘C:\Program Files\nodejs\node.exe’,
1 verbose cli ‘C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js’,
1 verbose cli ‘run’,
1 verbose cli ‘test’
1 verbose cli ]
2 info using npm@6.12.0
3 info using node@v12.13.0
4 verbose run-script [ ‘pretest’, ‘test’, ‘posttest’ ]
5 info lifecycle @pnp/office365-cli@2.3.0~pretest: @pnp/office365-cli@2.3.0
6 info lifecycle @pnp/office365-cli@2.3.0~test: @pnp/office365-cli@2.3.0
7 verbose lifecycle @pnp/office365-cli@2.3.0~test: unsafe-perm in lifecycle true
8 verbose lifecycle @pnp/office365-cli@2.3.0~test: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\PatrickLamber\Documents\GitHub\office365-cli\node_modules.bin;C:\Python27;C:\Python27\Scripts;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git\cmd;C:\Program Files\nodejs;C:\ProgramData\chocolatey\bin;C:\Users\PatrickLamber\AppData\Local\Microsoft\WindowsApps;C:\Users\PatrickLamber\AppData\Local\GitHubDesktop\bin;C:\Users\PatrickLamber\AppData\Local\Programs\Fiddler;C:\Users\PatrickLamber\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\PatrickLamber\AppData\Roaming\npm
9 verbose lifecycle @pnp/office365-cli@2.3.0~test: CWD: C:\Users\PatrickLamber\Documents\GitHub\office365-cli
10 silly lifecycle @pnp/office365-cli@2.3.0~test: Args: [ ‘/d /s /c’, ‘nyc -r=lcov -r=text mocha “dist/**/*.spec.js”’ ]
11 silly lifecycle @pnp/office365-cli@2.3.0~test: Returned: code: 1 signal: null
12 info lifecycle @pnp/office365-cli@2.3.0~test: Failed to exec test script
13 verbose stack Error: @pnp/office365-cli@2.3.0 test: nyc -r=lcov -r=text mocha "dist/**/*.spec.js"
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:210:5)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:210:5)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid @pnp/office365-cli@2.3.0
15 verbose cwd C:\Users\PatrickLamber\Documents\GitHub\office365-cli
16 verbose Windows_NT 10.0.18362
17 verbose argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “run” “test”
18 verbose node v12.13.0
19 verbose npm v6.12.0
20 error code ELIFECYCLE
21 error errno 1
22 error @pnp/office365-cli@2.3.0 test: nyc -r=lcov -r=text mocha "dist/**/*.spec.js"
22 error Exit status 1
23 error Failed at the @pnp/office365-cli@2.3.0 test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
I tried to figure out what might be the problem but I am not able to find the issue. By chance do you see what the problem might be in the output above?
Thank you for your feedback, Patrick
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 38 (37 by maintainers)
Hi, I have the issue with node v12.13.0 but also had the issue with node 10 on the same machine.
br, Patrick
@waldekmastykarz: works meanwhile.Closing the issue
As we have just released v2.5 of the CLI this should no longer be an issue, as we have replaced istanbuljs (nyc) with c8 as our test coverage tool in this release.
@eiriksanderfjeld @plamber can you confirm that the issue no longer remains when using the latest version of the CLI on a clean Windows install?
Please note that you will now require node v12 from v2.5 onwards, we will be updating our documentation to reflect this dependency under issue #1312.
Hi, i cloned the repo on a fresh windows 10 install (1909) and installed node 12.13.1. I got the same error as @plamber. I removed nyc, and installed 15.0.0-beta.0, which solved the original problem. However three tests (spfx project externalize, spfx project externalize, spfx project externalize) fails.
I will try to do the test fix next week and let you know if all is good.
According to this istanbuljs/nyc#1205 v14 will not solve the issue, it is
15.0.0-beta.1
and then v15 when it is out. I tested it with15.0.0-beta.1
it was working ok.@waldekmastykarz, it fails because of
nyc
module in the dev dependencies.The test is a side effect after the upgrade.
@plamber , @garrytrinder , @waldekmastykarz I was able to repro with
Possible solutions:
nyc
to15.0.0-beta.0
solved the issue as mentionaed here: https://github.com/istanbuljs/nyc/issues/1205nyc
to15.0.0-beta.1
solved the issue as wellnyc
did not worked for me.nyc
to15.0.0
should work best, but we have to wait until released.The unit test fails because, I ASSUME there has been update in Node 12
require
to output more information, therefore the assertion fails since the expectation for a shorter message. However, if there is a missing module that message is actually longer than the assertion so perhaps we should align the unit test.This is the actual error coming from
require
.We have just
Error: Cannot find module './project-upgrade/upgrade-0
in the assertion.Found another closed issue which is a potential fix
https://github.com/istanbuljs/nyc/issues/1163
Looks like the issue lies with npm 6.11 and not node, I’ll take a look at testing the fix later this afternoon.
Got it. Shall we then rename this issue to make it clear that it’s specific to Node v12 and then we can use it to track the work towards supporting it?
Regarding Istanbul, I’ve been delaying its upgrade, because each time I did it, the coverage report got empty. After trying out some fixes, I got it to show something, but not the 100% we have, which is odd, given it’s the same code.
With that said, Node v12 is LTS so we should definitely start looking into ways of supporting it. Also, the version of Istanbul that we’re using is quite old so it would be good to upgrade to the latest too.
Will try repro to tomorrow.
Hi, I am getting the project test failure also on my MAC. I ignored it so far because I was still able to commit my changes without affecting the coverage.
Hope this helps
I will try on fresh VM and let you know.