sails-permissions icon indicating copy to clipboard operation
sails-permissions copied to clipboard

import _ from 'lodash' how to fixed ?

Open NoGeneral opened this issue 9 years ago • 6 comments

node_modules/sails-permissions/api/services/ModelService.js:1 import _ from 'lodash' ^^^^^^

SyntaxError: Unexpected token import at exports.runInThisContext (vm.js:54:16) at Module._compile (module.js:375:25) at Object.Module._extensions..js (module.js:406:10) at Module.load (module.js:345:32) at Function.Module._load (module.js:302:12) at Module.require (module.js:355:17) at require (internal/module.js:13:17) at Object. (/api/services/ModelService.js:1:57) at Object. (/api/services/ModelService.js:1:189) at Module._compile (module.js:399:26) at Object.Module._extensions..js (module.js:406:10) at Module.load (module.js:345:32) at Function.Module._load (module.js:302:12) at Module.require (module.js:355:17) at require (internal/module.js:13:17) at /Users/lynn/hongcai/wlb/node_modules/include-all/index.js:129:29 at Array.forEach (native) at requireAll (/Users/lynn/hongcai/wlb/node_modules/include-all/index.js:44:9) at buildDictionary (/Users/lynn/hongcai/wlb/node_modules/sails-build-dictionary/index.js:68:14) at Function.module.exports.optional (/Users/lynn/hongcai/wlb/node_modules/sails-build-dictionary/index.js:160:9) at Hook.loadServices (/Users/lynn/hongcai/wlb/node_modules/sails/lib/hooks/moduleloader/index.js:310:23) at Hook.bound as loadServices

NoGeneral avatar Dec 16 '15 13:12 NoGeneral

Which versions of sails, sails-auth, and sails-permissions are you using?

khchan avatar Dec 16 '15 13:12 khchan

sails 11.3 sails-auth 1.3.1 sails-permissions 2.1.11

NoGeneral avatar Dec 17 '15 07:12 NoGeneral

node v5.2.0

NoGeneral avatar Dec 17 '15 07:12 NoGeneral

Everything is explained well here:

https://github.com/tjwebb/sails-permissions/issues/126#issuecomment-160094325

Try to follow all the steps patiently and correctly.

ehsankhf avatar Dec 17 '15 08:12 ehsankhf

I just grappled with this issue for a couple hours only to realize that the error was caused by me trying to extend the base sails-permissions files explicitly. Unbeknownst to me, the installed sails-permissions includes a dist folder that has transpiled the import statements to the functional require statements.

Unfortunately, I didn't realize there was a dist folder generated and I was referencing the files that weren't transpiled. This caused the above error. I spent most of my time trying to track down how to use import in node and then finally realized my real problem was referencing the wrong files!

I'm not sure if this is your problem, but it might be!

joshmatz avatar Jan 31 '16 21:01 joshmatz

Hi @joshmatz I am also facing the same issue. And it seems like not generating any dist file. But the error message SyntaxError: Unexpected reserved word is showing. I have searched a lot and did not get any clear clarification from anywhere.

muneermuhammed avatar Jun 07 '16 12:06 muneermuhammed