ENOENT: no such file or directory, open 'force/empApiInternal'

528    Asked by AndrewJenkins in Salesforce , Asked on Jul 2, 2021

 I'm trying to implement Platform Events into my LWC - I'm following these docs: lightning-emp-api docs.

When I try and import the empApi into my LWC I get the following error: (NB, it only occurs in the local dev server, when I deploy to my sandbox it works perfectly fine)

Could not load force/empApiInternal (imported by /Users//.local/share/sfdx/node_modules/@salesforce/lwc-dev-server-dependencies/vendors/dependencies-224/lightning-pkg/src/lightning/empApi/empApi.js): ENOENT: no such file or directory, open 'force/empApiInternal'


My import :


import { subscribe, unsubscribe, onError, setDebugFlag, isEmpEnabled } from 'lightning/empApi'; I know I could just constantly deploy to my org during development, but thats such a bad experience, I want to make sure it the only option. How do I fix error Enoent No such file or directory open?

Answered by Ankesh Kumar

Unfortunately, that's the case. The EMP is a Salesforce-specific feature, so you can't use it in the lwc-oss standalone. You'll get better deployment performance if you use a Scratch Org, though (on average, anyways). Follow these steps to fix error “enoent: no such file or directory, open”: delete node-modules folder. run command npm cache clean --force. run command npm install. install the package again with npm install your-package-name.



Your Answer

Interviews

Parent Categories