Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to run npm run test on fresh Windows install #1188

Closed
plamber opened this issue Nov 11, 2019 · 38 comments
Closed

Not able to run npm run test on fresh Windows install #1188

plamber opened this issue Nov 11, 2019 · 38 comments
Labels

Comments

@plamber
Copy link
Contributor

plamber commented Nov 11, 2019

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/[email protected] 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/[email protected] test: nyc -r=lcov -r=text mocha "dist/**/*.spec.js"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @pnp/[email protected] 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 [email protected]
3 info using [email protected]
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle @pnp/[email protected]pretest: @pnp/[email protected]
6 info lifecycle @pnp/[email protected]
test: @pnp/[email protected]
7 verbose lifecycle @pnp/[email protected]test: unsafe-perm in lifecycle true
8 verbose lifecycle @pnp/[email protected]
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/[email protected]test: CWD: C:\Users\PatrickLamber\Documents\GitHub\office365-cli
10 silly lifecycle @pnp/[email protected]
test: Args: [ '/d /s /c', 'nyc -r=lcov -r=text mocha "dist/**/*.spec.js"' ]
11 silly lifecycle @pnp/[email protected]test: Returned: code: 1 signal: null
12 info lifecycle @pnp/[email protected]
test: Failed to exec test script
13 verbose stack Error: @pnp/[email protected] test: nyc -r=lcov -r=text mocha "dist/**/*.spec.js"
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (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. (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/[email protected]
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/[email protected] test: nyc -r=lcov -r=text mocha "dist/**/*.spec.js"
22 error Exit status 1
23 error Failed at the @pnp/[email protected] 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

@waldekmastykarz
Copy link
Member

Could you see if you can repro the issue on Node v10? Also, how did you install Node?

@plamber
Copy link
Contributor Author

plamber commented Nov 11, 2019

I am able to reproduce the error with the 12.13.0 LTS 64 bits version. The installation has been executed using the MSI package. I tried it out with the 64 version located under https://nodejs.org/dist/latest-v10.x/ and got these results.

Error: Cannot find module 'C:\Users\PatrickLamber\Documents\GitHub\office365-cli\node'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
----------|----------|----------|----------|----------|-------------------|
npm ERR! Test failed. See above for more details.

@VelinGeorgiev
Copy link
Contributor

Could it be something in the npm-shrinkwrap.json file?

Patrick @plamber, can you try

  • rename the npm-shrinkwrap.json file to something else so npm will not use it.
  • delete the node_modules directory
  • delete the package-lock.json file if such
  • npm install

Note: This will create package-lock.json file that must be deleted if we find out the issue is with npm-shrinkwrap.json file and fix it.

@plamber
Copy link
Contributor Author

plamber commented Nov 12, 2019

Hi,
installed the 12.13.0 LTS version.

By following @VelinGeorgiev steps, I started receiving hundrets of errors when building the project.

src/request.spec.ts:60:44 - error TS2345: Argument of type '(options: string | URL) => WriteStream' is not assignable to parameter of type '(url: string | URL, options: RequestOptions, callback?: ((res: IncomingMessage) => void) | undefined) => ClientRequest'.
Type 'WriteStream' is missing the following properties from type 'ClientRequest': connection, socket, aborted, abort, and 19 more.

60 sinon.stub(https, 'request').callsFake((options) => {
~~~~~~~~~~~~~~

When putting the npm-shrinkwrap.json back as before... everything except npm run test was working again.

@plamber
Copy link
Contributor Author

plamber commented Nov 12, 2019

Hi,
I performed some additional tests:

  • Executed the steps on a Mac... no problems at all
  • Created a secondary profile on my Windows 10 Machine. The problem still persists

br,
Patrick

@waldekmastykarz
Copy link
Member

Could you try using Node v10 and see if you can repro the issue?

@plamber
Copy link
Contributor Author

plamber commented Nov 13, 2019

Tried it with Node v10 and I am able to reproduce the error. I also tried to create a local account to see if it might be somehow related to my Azure AD joined account.

Meanwhile, I even tried the radical approach. I reset my PC and focused on installing only the necessary components. Same error.

@waldekmastykarz
Copy link
Member

Thanks for confirming @plamber. @VelinGeorgiev, you're on Windows right? Can you reproduce this issue?

@VelinGeorgiev
Copy link
Contributor

VelinGeorgiev commented Nov 14, 2019

I will try on fresh VM and let you know.

@waldekmastykarz
Copy link
Member

Hey @VelinGeorgiev, any updates?

@garrytrinder
Copy link
Member

I've been able to replicate the same issue on Windows 10 Pro 1903 (19008.1000) & Node LTS 12.13.1, following the same 'Minimal Path to Awesome' as Patrick.

image

As the issue is relating to running the tests, it would appear that based on the error stack below, that nyc is causing the issue here.

Error: Cannot find module 'C:\github\office365-cli\node'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: }

After a little bit of digging, I found this closed issue istanbuljs/nyc#1205 which suggests using a beta version of nyc 15 instead to fix the issue.

I have tried the above fix and can confirm that this does resolve the issue, but that it does also result in a test failure spfx project upgrade: shows error when a upgrade rule failed which may or may not be related.

@waldekmastykarz @VelinGeorgiev

@plamber
Copy link
Contributor Author

plamber commented Nov 25, 2019

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

@waldekmastykarz
Copy link
Member

@plamber @garrytrinder is this issue specific to Node v12?

@VelinGeorgiev
Copy link
Contributor

Will try repro to tomorrow.

@garrytrinder
Copy link
Member

I’ve not had chance to test with another version but the closed issue refers to it only being an issue with Node v12.11.0 and higher.

@waldekmastykarz
Copy link
Member

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.

@garrytrinder
Copy link
Member

Agree on renaming the issue 👍🏻

We first need to confirm the working Node version and go from there, once we know what that version is it will help us get a clearer plan of attack.

I’ll take a look confirming this later this evening.

@garrytrinder
Copy link
Member

I have downgraded to Node 12.10.0 and can confirm that tests do run without upgrading nyc to the 15.0.0-beta.0 version, however an error is still thrown after the test results table is shown.

image

Debug log below

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 [email protected]
3 info using [email protected]
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle @pnp/[email protected]~pretest: @pnp/[email protected]
6 info lifecycle @pnp/[email protected]~test: @pnp/[email protected]
7 verbose lifecycle @pnp/[email protected]~test: unsafe-perm in lifecycle true
8 verbose lifecycle @pnp/[email protected]~test: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\github\office365-cli\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Parallels\Parallels Tools\Applications;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;C:\Users\Garry.Trinder\AppData\Local\Programs\Python\Python38-32\Scripts\;C:\Users\Garry.Trinder\AppData\Local\Programs\Python\Python38-32\;C:\Users\Garry.Trinder\AppData\Local\Microsoft\WindowsApps;C:\Users\Garry.Trinder\AppData\Local\Programs\Fiddler;C:\Users\Garry.Trinder\AppData\Local\Microsoft\WindowsApps;C:\Users\Garry.Trinder\AppData\Roaming\npm
9 verbose lifecycle @pnp/[email protected]~test: CWD: C:\github\office365-cli
10 silly lifecycle @pnp/[email protected]~test: Args: [ '/d /s /c', 'nyc -r=lcov -r=text mocha "dist/**/*.spec.js"' ]
11 silly lifecycle @pnp/[email protected]~test: Returned: code: 1  signal: null
12 info lifecycle @pnp/[email protected]~test: Failed to exec test script
13 verbose stack Error: @pnp/[email protected] 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:326:16)
13 verbose stack     at EventEmitter.emit (events.js:209:13)
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:209:13)
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/[email protected]
15 verbose cwd C:\github\office365-cli
16 verbose Windows_NT 10.0.19008
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.10.0
19 verbose npm  v6.10.3
20 error code ELIFECYCLE
21 error errno 1
22 error @pnp/[email protected] test: `nyc -r=lcov -r=text mocha "dist/**/*.spec.js"`
22 error Exit status 1
23 error Failed at the @pnp/[email protected] test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@garrytrinder
Copy link
Member

garrytrinder commented Nov 25, 2019

Oddly, downgrading further to Node 10.17.0, the last LTS build for Node v10, the tests don't run at all.

image

Debug log below

0 info it worked if it ends with ok
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' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle @pnp/[email protected]~pretest: @pnp/[email protected]
6 info lifecycle @pnp/[email protected]~test: @pnp/[email protected]
7 verbose lifecycle @pnp/[email protected]~test: unsafe-perm in lifecycle true
8 verbose lifecycle @pnp/[email protected]~test: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\github\office365-cli\node_modules\.bin;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Parallels\Parallels Tools\Applications;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin;C:\Program Files\nodejs\;C:\Users\Garry.Trinder\AppData\Local\Programs\Python\Python38-32\Scripts\;C:\Users\Garry.Trinder\AppData\Local\Programs\Python\Python38-32\;C:\Users\Garry.Trinder\AppData\Local\Microsoft\WindowsApps;C:\Users\Garry.Trinder\AppData\Local\Programs\Fiddler;C:\Users\Garry.Trinder\AppData\Local\Microsoft\WindowsApps;C:\Users\Garry.Trinder\AppData\Roaming\npm
9 verbose lifecycle @pnp/[email protected]~test: CWD: C:\github\office365-cli
10 silly lifecycle @pnp/[email protected]~test: Args: [ '/d /s /c', 'nyc -r=lcov -r=text mocha "dist/**/*.spec.js"' ]
11 silly lifecycle @pnp/[email protected]~test: Returned: code: 1  signal: null
12 info lifecycle @pnp/[email protected]~test: Failed to exec test script
13 verbose stack Error: @pnp/[email protected] 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:198:13)
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:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid @pnp/[email protected]
15 verbose cwd C:\github\office365-cli
16 verbose Windows_NT 10.0.19008
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 v10.17.0
19 verbose npm  v6.11.3
20 error code ELIFECYCLE
21 error errno 1
22 error @pnp/[email protected] test: `nyc -r=lcov -r=text mocha "dist/**/*.spec.js"`
22 error Exit status 1
23 error Failed at the @pnp/[email protected] test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@garrytrinder
Copy link
Member

@plamber do you still have access to your old machine? If so, would it be possible to find out what version of node was installed on it?

@plamber
Copy link
Contributor Author

plamber commented Nov 26, 2019

Hi,
I have the issue with node v12.13.0 but also had the issue with node 10 on the same machine.

br,
Patrick

@garrytrinder
Copy link
Member

Found another closed issue which is a potential fix

istanbuljs/nyc#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.

@VelinGeorgiev
Copy link
Contributor

VelinGeorgiev commented Nov 27, 2019

@plamber , @garrytrinder , @waldekmastykarz I was able to repro with

λ node -v
v12.13.1
λ npm -v
6.12.1
Windows 10 Pro 1809

Possible solutions:

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.

Error: Cannot find module './project-upgrade/upgrade-0'
Require stack:
- C:\cmder\office365-cli\dist\o365\spfx\commands\project\project-upgrade.js
- C:\cmder\office365-cli\dist\o365\spfx\commands\project\project-upgrade.spec.js
- C:\cmder\office365-cli\node_modules\mocha\lib\mocha.js
- C:\cmder\office365-cli\node_modules\mocha\lib\cli\one-and-dones.js
- C:\cmder\office365-cli\node_modules\mocha\lib\cli\options.js
- C:\cmder\office365-cli\node_modules\mocha\bin\mocha
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at Module.patchedRequire [as require] (C:\cmder\office365-cli\node_modules\diagnostic-channel\dist\src\patchRequire.js:14:46)
    at require (internal/modules/cjs/helpers.js:74:18)
    at C:\cmder\office365-cli\dist\o365\spfx\commands\project\project-upgrade.js:3:261
    at Array.forEach (<anonymous>)
    at SpfxProjectUpgradeCommand.commandAction (C:\cmder\office365-cli\dist\o365\spfx\commands\project\project-upgrade.js:3:180)
    at Object.action (C:\cmder\office365-cli\dist\o365\spfx\commands\project\project-upgrade.js:1:85015)
    at Context.<anonymous> (C:\cmder\office365-cli\dist\o365\spfx\commands\project\project-upgrade.spec.js:459:21)
    at callFn (C:\cmder\office365-cli\node_modules\mocha\lib\runnable.js:387:21)
    at Test.Runnable.run (C:\cmder\office365-cli\node_modules\mocha\lib\runnable.js:379:7)
    at Runner.runTest (C:\cmder\office365-cli\node_modules\mocha\lib\runner.js:535:10)
    at C:\cmder\office365-cli\node_modules\mocha\lib\runner.js:653:12
    at next (C:\cmder\office365-cli\node_modules\mocha\lib\runner.js:447:14)
    at C:\cmder\office365-cli\node_modules\mocha\lib\runner.js:457:7
    at next (C:\cmder\office365-cli\node_modules\mocha\lib\runner.js:362:14)
    at C:\cmder\office365-cli\node_modules\mocha\lib\runner.js:420:7
    at done (C:\cmder\office365-cli\node_modules\mocha\lib\runnable.js:334:5)
    at callFn (C:\cmder\office365-cli\node_modules\mocha\lib\runnable.js:410:7)
    at Hook.Runnable.run (C:\cmder\office365-cli\node_modules\mocha\lib\runnable.js:379:7)
    at next (C:\cmder\office365-cli\node_modules\mocha\lib\runner.js:384:10)
    at Immediate._onImmediate (C:\cmder\office365-cli\node_modules\mocha\lib\runner.js:425:5)
    at processImmediate (internal/timers.js:439:21) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\cmder\\office365-cli\\dist\\o365\\spfx\\commands\\project\\project-upgrade.js',
    'C:\\cmder\\office365-cli\\dist\\o365\\spfx\\commands\\project\\project-upgrade.spec.js',
    'C:\\cmder\\office365-cli\\node_modules\\mocha\\lib\\mocha.js',
    'C:\\cmder\\office365-cli\\node_modules\\mocha\\lib\\cli\\one-and-dones.js',
    'C:\\cmder\\office365-cli\\node_modules\\mocha\\lib\\cli\\options.js',
    'C:\\cmder\\office365-cli\\node_modules\\mocha\\bin\\mocha'
  ]
}
CommandError {
  message: "Cannot find module './project-upgrade/upgrade-0'\n" +
    'Require stack:\n' +
    '- C:\\cmder\\office365-cli\\dist\\o365\\spfx\\commands\\project\\project-upgrade.js\n' +
    '- C:\\cmder\\office365-cli\\dist\\o365\\spfx\\commands\\project\\project-upgrade.spec.js\n' +
    '- C:\\cmder\\office365-cli\\node_modules\\mocha\\lib\\mocha.js\n' +
    '- C:\\cmder\\office365-cli\\node_modules\\mocha\\lib\\cli\\one-and-dones.js\n' +
    '- C:\\cmder\\office365-cli\\node_modules\\mocha\\lib\\cli\\options.js\n' +
    '- C:\\cmder\\office365-cli\\node_modules\\mocha\\bin\\mocha',
  code: undefined
}
    1) shows error when a upgrade rule failed

We have just Error: Cannot find module './project-upgrade/upgrade-0 in the assertion.

@waldekmastykarz
Copy link
Member

So it fails because of a single test? If that's the case, couldn't we adjust that one test rather than go down the route of fixing dependencies?

@VelinGeorgiev
Copy link
Contributor

@waldekmastykarz, it fails because of nyc module in the dev dependencies.

The test is a side effect after the upgrade.

@waldekmastykarz
Copy link
Member

After upgrading nyc, have you had a look at the coverage report? It was showing empty for me in v14 and I wonder if it's still an issue with v15.

@VelinGeorgiev
Copy link
Contributor

VelinGeorgiev commented Nov 27, 2019

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 with 15.0.0-beta.1 it was working ok.

@waldekmastykarz
Copy link
Member

Have you checked the coverage report produced by v15 @VelinGeorgiev?

@VelinGeorgiev
Copy link
Contributor

Yes, I did. One test is failing. We will have to fix it.

@waldekmastykarz
Copy link
Member

But the coverage itself is still 100%?

@VelinGeorgiev
Copy link
Contributor

I will try to do the test fix next week and let you know if all is good.

@eiriksanderfjeld
Copy link

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.

@VelinGeorgiev
Copy link
Contributor

VelinGeorgiev commented Dec 5, 2019

@eiriksanderfjeld thanks for reporting that! I will try to apply a fix and fix tests until the end of the week.

@garrytrinder
Copy link
Member

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.

@plamber
Copy link
Contributor Author

plamber commented Jan 9, 2020

@garrytrinder

I was able to successfully test the project with the latest release. Just some notes.

after running npm install, my npm-shrinkwrap.json has been changed
the URL "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz" changed to "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz" (from https to http)

These tests fail
spfx project externalize - returns text report with output format default
AssertionError [ERR_ASSERTION]: 'In the config/config.json file update the externals property to:\r\n' +
'\r\n' +
'{\n' +
' "externals": {\n' +
' "@pnp/pnpjs": {\n' +
' "path": "https://unpkg.com/@pnp/[email protected]/dist/pnpjs.es5.umd.min.js",\n' +
' "globalName": "pnp"\n' +
' }\n' +
' }\n' +
'}' == 'In the config/config.json file update the externals property to:\n' +
'\n' +
'{\n' +
' "externals": {\n' +
' "@pnp/pnpjs": {\n' +
' "path": "https://unpkg.com/@pnp/[email protected]/dist/pnpjs.es5.umd.min.js",\n' +
' "globalName": "pnp"\n' +
' }\n' +
' }\n' +
'}'
+ expected - actual
-In the config/config.json file update the externals property to:
-
+In the config/config.json file update the externals property to:
+
{
"externals": {
"@pnp/pnpjs": {
"path": "https://unpkg.com/@pnp/[email protected]/dist/pnpjs.es5.umd.min.js",

  at C:\Users\PatrickLamber\Documents\GitHub\office365-cli\dist\o365\spfx\commands\project\project-externalize.spec.js:597:24
  at C:\Users\PatrickLamber\Documents\GitHub\office365-cli\dist\o365\spfx\commands\project\project-externalize.js:94:13

spfx project externalize - covers all text report branches
AssertionError [ERR_ASSERTION]: 89 == 87
+ expected - actual
-89
+87

  at Context.<anonymous> (dist\o365\spfx\commands\project\project-externalize.spec.js:621:16)
  at processImmediate (internal/timers.js:439:21)

@waldekmastykarz
Copy link
Member

Good to hear you're unblocked @plamber 👍

after running npm install, my npm-shrinkwrap.json has been changed

This happens occasionally. The best is to ignore npmshrinkwrap changes when committing your changes.

As for the failing test, that's something we need to investigate. It shouldn't be the case.

@waldekmastykarz
Copy link
Member

@plamber is this still an issue?

@plamber
Copy link
Contributor Author

plamber commented Feb 11, 2020

@waldekmastykarz: works meanwhile.Closing the issue

@plamber plamber closed this as completed Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants