Seeing import _ from 'lodash' error
sidster-io opened this issue · comments
node_modules/node-summary/lib/summary.js:1
(function (exports, require, module, __filename, __dirname) { import _ from 'lodash'
on node version v11.6.0
Can you try the version on master?
Sorry for the late reply. Will try it out 👍🏽
Running into a new issue.
Added "node-summary": "git+https://github.com/jbrooksuk/node-summary.git#master" to package.json
Seeing error /node_modules/node-summary/lib/summary.js:1 (function (exports, require, module, __filename, __dirname) { import { convertHTMLToText, getTitle } from './helpers/html'
Same error as @sidster-io from the master branch. @jbrooksuk maybe you need to add "type": "module"
to the package.json?
Same error here, v14.1.0
Same error as @sidster-io from the master branch. @jbrooksuk maybe you need to add
"type": "module"
to the package.json?
Possibly! I'm not overly familiar with how this works to be honest. Are you able to test this?
I think the problem is that you are using ES syntax along with CommonJS. You could try going through the code and make it work with CommonJS syntax. What I mean is changing statements like import {convertHTMLToText, getTitle} from './helpers/html.js';
to
const {convertHTMLToText, getTitle} = require("./helpers/html.js");
. You would also have to change export statements from export const getTitle = htmlBody = {<function code here>}
to module.exports.getTitle = (htmlBody) => {<function code here>}
I created a pull request fixing this issue(#50). You can use that instead the main package by using the command (or just wait him fix the issue / or merge the PR):
npm install https://github.com/TroniPM/node-summary
@jbrooksuk Looks like the master version is not in npm and the issue continues. Can you please publish master version to npm ?
/node_modules/node-summary/lib/summary.js:1
import _ from 'lodash'
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1067:16)
at Module._compile (internal/modules/cjs/loader.js:1115:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1040:19)
at require (internal/modules/cjs/helpers.js:72:18)
on windows with node v16.14.0
import _ from 'lodash'
^^^^^^
SyntaxError: Cannot use import statement outside a module
I created a pull request fixing this issue(#50). You can use that instead the main package by using the command (or just wait him fix the issue / or merge the PR):
npm install https://github.com/TroniPM/node-summary
This works fine. Thank you
npm install https://github.com/TroniPM/node-summary
This still works like a charm! Thank you!