node-summary icon indicating copy to clipboard operation
node-summary copied to clipboard

Seeing import _ from 'lodash' error

Open sidster-io opened this issue 5 years ago • 13 comments

node_modules/node-summary/lib/summary.js:1 (function (exports, require, module, __filename, __dirname) { import _ from 'lodash'

on node version v11.6.0

sidster-io avatar Apr 30 '20 23:04 sidster-io

Can you try the version on master?

jbrooksuk avatar May 01 '20 12:05 jbrooksuk

Sorry for the late reply. Will try it out 👍🏽

sidster-io avatar May 10 '20 02:05 sidster-io

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'

sidster-io avatar May 10 '20 03:05 sidster-io

Same error as @sidster-io from the master branch. @jbrooksuk maybe you need to add "type": "module" to the package.json?

Niek avatar May 26 '20 13:05 Niek

Same error here, v14.1.0

Catsvilles avatar Jun 02 '20 12:06 Catsvilles

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?

jbrooksuk avatar Jun 18 '20 09:06 jbrooksuk

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>}

shadowtime2000 avatar Jul 02 '20 01:07 shadowtime2000

I created a pull request fixing this issue(https://github.com/jbrooksuk/node-summary/pull/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

TroniPM avatar Sep 30 '20 04:09 TroniPM

@jbrooksuk Looks like the master version is not in npm and the issue continues. Can you please publish master version to npm ? Screenshot 2021-02-03 at 4 27 59 PM Screenshot 2021-02-03 at 4 28 35 PM

suresharam avatar Feb 03 '21 10:02 suresharam

/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

jingkang99 avatar Apr 06 '22 03:04 jingkang99

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

Valentine-Mario avatar Oct 03 '22 08:10 Valentine-Mario

npm install https://github.com/TroniPM/node-summary

This still works like a charm! Thank you!

decidev22 avatar Nov 09 '23 14:11 decidev22