Cannot find module 'lodash'

Last week I was happily updating code for Electrons and flashing it locally and remotely to a range of Electron devices.

This week - without knowingly making any changes - I cannot compile tested code that ran last week.

On compiling I get the above message in the particle-cli

I have installed the workbench on a fresh desktop and all works fine.

I have removed the workbench from the original machine using the instructions at:

Troubleshooting the Particle Workbench | Troubleshooting | Particle.

and then carried out a re-install as per the same Guides page.

Install seemed to work as colour-theme has changed and a few new bits are showing (such as v1.15.10) bottom right but still get same error message on compiling and cannot login.

Help and suggestions please.

If you install lodash that error should go away.

npm install lodash --save

Let me know if you have any further issues.

Thank you for your reply.

In what environment do I run this line. I have tried in the cli terminal within the WorkBench but get

C:\ATC_data\Particle\Blink_with_SoC_reporting_17Oct21>npm install lodash --save

‘npm’ is not recognized as an internal or external command,

operable program or batch file.

Tom Chamberlain

I have loaded node.js onto my laptop and used the command line to download the lodash file.

On re-running I had a similar message re semver which I again downloaded.

I still could not compile my program.

I then removed the Workbench again following the uninstall instructions and re-installed the work bench. When I now try and complie my program in OS 2.3.1 for an electron I get the following messages in the terminal:

  • Executing task: make -f ‘C:\Users\drtom.particle\toolchains\buildscripts\1.10.0\Makefile’ compile-user -s

! Error in particle-cli:

! Unexpected token ‘export’

! See C:\Users\drtom\AppData\Local\particle\error.log for more info.

make: *** [C:\Users\drtom.particle\toolchains\buildscripts\1.10.0\Makefile:37: c:/ATC_data/Particle/Blink_with_SoC_reporting_17Oct21/src/Blink_with_SoC_reporting_17Oct21.cpp] Error 1

  • The terminal process “C:\Users\drtom.particle\toolchains\buildtools\1.1.1\bin\bash.exe ‘-c’, ‘make -f ‘C:\Users\drtom.particle\toolchains\buildscripts\1.10.0\Makefile’ compile-user -s’” terminated with exit code: 2.

  • Press any key to close the terminal.

And in the errorlog file

SyntaxError: Unexpected token ‘export’

at wrapSafe (internal/modules/cjs/loader.js:1072:16)

at Module._compile (internal/modules/cjs/loader.js:1122:27)

at Object.Module._extensions…js (internal/modules/cjs/loader.js:1178:10)

at Module.load (internal/modules/cjs/loader.js:1002:32)

at Function.Module._load (internal/modules/cjs/loader.js:901:14)

at Module.require (internal/modules/cjs/loader.js:1044:19)

at require (internal/modules/cjs/helpers.js:77:18)

at Object. (C:\Users\drtom\AppData\Local\particle\node_modules\particle-cli\node_modules\chalk\index.js:2:28)

at Module._compile (internal/modules/cjs/loader.js:1158:30)

at Object.Module._extensions…js (internal/modules/cjs/loader.js:1178:10)

2023/03/30 11:47:35 Time since last update 7m44.3475922s, update in background

What next?

Tom Chamberlain

I have encountered a this same issue with my Particle VS workbench. I suddenly can’t do anything, login, create a new project, compile etc. without encountering a “cannot find module ‘lodash’ error”

I’ve already referred to the above posts but it seems to have never been resolved for the original poster so I’m looking for some fresh suggestions.

I’ve followed the workbench troubleshooting with no success.

I also don’t know how to use npm -i lodash.

Please advise as this is a catastrophic failure for our product development.

below is my current error log

Error in particle-cli:
 !   Cannot find module 'lodash'
Require stack:
- C:\Users\valen\AppData\Local\particle\node_modules\particle-cli\src\lib\has-supported-node.js
- C:\Users\valen\AppData\Local\particle\node_modules\particle-cli\src\index.js
- C:\Users\valen\AppData\Local\particle\[eval]
 !   See C:\Users\valen\AppData\Local\particle\error.log for more info.
Error: Command failed with exit code 1: c:\Users\valen\.vscode\extensions\particle.particle-vscode-core-1.16.0\src\cli\bin\windows\amd64\particle.exe login -u valentina@transaera.com -p byv1edh!RQJ.vck-ftb --otp - --no-update-check
 !   Error in particle-cli:
 !   Cannot find module 'lodash'
Require stack:
- C:\Users\valen\AppData\Local\particle\node_modules\particle-cli\src\lib\has-supported-node.js
- C:\Users\valen\AppData\Local\particle\node_modules\particle-cli\src\index.js
- C:\Users\valen\AppData\Local\particle\[eval]
 !   See C:\Users\valen\AppData\Local\particle\error.log for more info.
	at makeError (c:\Users\valen\.vscode\extensions\particle.particle-vscode-core-1.16.0\node_modules\execa\lib\error.js:59:11)
	at handlePromise (c:\Users\valen\.vscode\extensions\particle.particle-vscode-core-1.16.0\node_modules\execa\index.js:114:26)
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async LoginCommand.loginWithUsername (c:\Users\valen\.vscode\extensions\particle.particle-vscode-core-1.16.0\src\commands\lib\login.js:81:17)
	at async LoginCommand.exec (c:\Users\valen\.vscode\extensions\particle.particle-vscode-core-1.16.0\src\commands\command.js:39:13)
	at async e.ExtHostCommands.h (c:\Users\valen\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:125307)

- - - -


I would follow these instructions, then reinstall.

Note that the node-(some number) directory will likely be different than in that post as we've upgraded since then, but use whatever the version installed on your machine is.

Somewhere I read that should not be connected to the internet so I unplugged my laptop and the problem has not occurred since. Sorry this is a bit vague but it sorted the problem so on to the next problem.

Ended up taking the following approach which reset the CLI. This has seemed to do the trick.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.