trailsjs / sails-permissions

Comprehensive user permissions and entitlements system for sails.js and Waterline. Supports user authentication with passport.js, role-based permissioning, object ownership, and row-level security.
MIT License
418 stars 113 forks source link

import _ from 'lodash' how to fixed ? #198

Closed NoGeneral closed 1 year ago

NoGeneral commented 8 years ago

nodemodules/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

khchan commented 8 years ago

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

NoGeneral commented 8 years ago

sails 11.3 sails-auth 1.3.1 sails-permissions 2.1.11

NoGeneral commented 8 years ago

node v5.2.0

ehsankhf commented 8 years ago

Everything is explained well here:

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

Try to follow all the steps patiently and correctly.

joshmatz commented 8 years ago

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!

muneermuhammed commented 8 years ago

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.