Description of the Issue
I am importing box-node-sdk into an ES6 Node application and am getting an error at "compile"-time when packaging
node_modules/vm2/lib/resolver-compat.js:169:33: error: Could not resolve "async_hooks" (set platform to "node" when building for node)
169 │ const {AsyncResource} = require('async_hooks');
Steps to Reproduce
- % npm init lwr
- % cd lwr-project
- % yarn add box-node-sdk
- Edit lwr-project/src/modules/example/app/app.js and add the following line at the top of the file :
import { BoxSDK } from 'box-node-sdk'
- % yarn install
- % yarn dev
- Open http://localhost:3000 : this starts the compilation/packaging process
LWR reference documentation :
https://developer.salesforce.com/docs/platform/lwr/guide/lwr-intro.html
Expected Behavior
The application should compile/get packaged correctly
Error Message, Including Stack Trace
rupert@MacBook-Pro-de-Rupert lwr-project % yarn dev
yarn run v1.22.17
$ lwr serve
server running at: port: 3000 | mode: dev
Watching: /Users/rupert/Workspaces/test/lwr-project/src/modules/example/app/app.js
node_modules/vm2/lib/resolver-compat.js:29:8: warning: This call to "require" will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning)
29 │ return require(/* webpackIgnore: true */ moduleName);
╵ ~~~~~~~
node_modules/vm2/lib/resolver-compat.js:169:33: error: Could not resolve "async_hooks" (set platform to "node" when building for node)
169 │ const {AsyncResource} = require('async_hooks');
╵ ~~~~~~~~~~~~~
[ERROR]resolveNpmModules(esbuild): {
specifier: 'box-node-sdk',
dest: '/Users/rupert/Workspaces/test/lwr-project/lwr_cache/web_modules'
}
LWR Diagnostic Error: 404: Could not find module entry with specifier "box-node-sdk"
[
{
description: {
category: 'lwrUnresolvable/module',
advice: [],
message: '404: Could not find module entry with specifier "box-node-sdk"'
}
}
]
DiagnosticsError: 404: Could not find module entry with specifier "box-node-sdk"
at createSingleDiagnosticError (file:///Users/rupert/Workspaces/test/lwr-project/node_modules/@lwrjs/diagnostics/build/es/errors.js:6:12)
at LwrModuleRegistry.delegateGetModuleEntryOnServices (file:///Users/rupert/Workspaces/test/lwr-project/node_modules/@lwrjs/module-registry/build/es/index.js:214:15)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async resolveExternalImport (file:///Users/rupert/Workspaces/test/lwr-project/node_modules/@lwrjs/module-registry/build/es/module-record.js:39:35)
at async getModuleRecord (file:///Users/rupert/Workspaces/test/lwr-project/node_modules/@lwrjs/module-registry/build/es/module-record.js:80:44)
at async LwrModuleRegistry.createModuleDefinition (file:///Users/rupert/Workspaces/test/lwr-project/node_modules/@lwrjs/module-registry/build/es/index.js:103:30)
at async getModuleGraphs (file:///Users/rupert/Workspaces/test/lwr-project/node_modules/@lwrjs/shared-utils/build/es/graph.js:117:11)
at async file:///Users/rupert/Workspaces/test/lwr-project/node_modules/@lwrjs/view-registry/build/es/linkers/legacy_view_bootstrap.js:107:23
at async Promise.all (index 0)
at async getHtmlResources (file:///Users/rupert/Workspaces/test/lwr-project/node_modules/@lwrjs/view-registry/build/es/linkers/legacy_view_bootstrap.js:106:5)
Screenshots
Versions Used
Node SDK: 2.0.0
The problem does not seem to occur with box-node-sdk 1.39.0
Description of the Issue
I am importing box-node-sdk into an ES6 Node application and am getting an error at "compile"-time when packaging
Steps to Reproduce
import { BoxSDK } from 'box-node-sdk'
LWR reference documentation :
https://developer.salesforce.com/docs/platform/lwr/guide/lwr-intro.html
Expected Behavior
The application should compile/get packaged correctly
Error Message, Including Stack Trace
rupert@MacBook-Pro-de-Rupert lwr-project % yarn dev
yarn run v1.22.17
$ lwr serve
server running at: port: 3000 | mode: dev
Watching: /Users/rupert/Workspaces/test/lwr-project/src/modules/example/app/app.js
[ERROR]resolveNpmModules(esbuild): {
specifier: 'box-node-sdk',
dest: '/Users/rupert/Workspaces/test/lwr-project/lwr_cache/web_modules'
}
LWR Diagnostic Error: 404: Could not find module entry with specifier "box-node-sdk"
[
{
description: {
category: 'lwrUnresolvable/module',
advice: [],
message: '404: Could not find module entry with specifier "box-node-sdk"'
}
}
]
DiagnosticsError: 404: Could not find module entry with specifier "box-node-sdk"
Screenshots
Versions Used
Node SDK: 2.0.0
The problem does not seem to occur with box-node-sdk 1.39.0