Skip to content
This repository was archived by the owner on Oct 4, 2023. It is now read-only.

can not use '__static' #248

Closed
lianshengxing opened this issue Jun 6, 2017 · 20 comments
Closed

can not use '__static' #248

lianshengxing opened this issue Jun 6, 2017 · 20 comments

Comments

@lianshengxing
Copy link

when i use 'let fileContents = fs.readFileSync(path.join(__static, '/Grgzpt.exe'), 'utf8')',it threw an error that '__static is not defined'

@SimulatedGREG
Copy link
Owner

@lianshengxing

The __static variable is a very new feature from the last milestone release from just a few days ago. If your project still has a two package.json structure with the app folder, then your scaffold isn't update to date with the current version.

@lianshengxing
Copy link
Author

@SimulatedGREG
so what should i do to updata to the current veision

@SimulatedGREG
Copy link
Owner

https://simulatedgreg.gitbooks.io/electron-vue/content/en/migration-guide.html

This is a good start, but isn't a full proof method. Depending on what you may have changed in your project, there could be other items to migrate manually.

@lianshengxing
Copy link
Author

@SimulatedGREG
excuse me,i i found two 'src' folders in the project, which one should i change

@SimulatedGREG
Copy link
Owner

This happened because of a vue-cli issue where a cached version of the template merges with an updated version. Make sure your vue-cli version is update to date with npm i -g vue-cli@latest.

Related: vuejs/vue-cli#450, #240

Items such as app, tasks, and config.js no longer exist. Make sure to reference the current template to check for the differences. https://github.com/SimulatedGREG/electron-vue/tree/master/template

@lianshengxing
Copy link
Author

i use the latest 'electron-vue' project, and when i use 'let fileContents = fs.readFileSync(path.join(__static, '/Grgzpt.exe'), 'utf8')' in the 'main/index.js',it threw an error that 'no such file or directory, open 'C:\Users\wzh-lian\Desktop\my-project\Userswzh-lianDesktopmy-projectstatic\Grgzpt.exe''

@SimulatedGREG
Copy link
Owner

open 'C:\Users\wzh-lian\Desktop\my-project\Userswzh-lianDesktopmy-projectstatic\Grgzpt.exe''

Not sure what you changed, but this path that was created surely doesn't look right.

@lianshengxing
Copy link
Author

in the 'main/index.js' ,you give the code that 'if (process.env.NODE_ENV !== 'development') {
global.__static = path.join(__dirname, '/static')
}',and then i use 'console.log(__static)',when i executed the command that 'npm run dev',the output is 'Userswzh-lianDesktopmy-projectstatic', but when i use 'console.log()__dirname)', the output is 'src/main', could you explain about that

@SimulatedGREG
Copy link
Owner

Related: #101
Fixed in: 37075c8

In short, win32 uses \ backslashes for file paths, but in JS Strings, these will be interpreted as escape delimiters.

@lianshengxing
Copy link
Author

@SimulatedGREG
thanks a lot for that,i have changed the project and it worked well. and then i want to use the 'shell.openItem' to open the 'Grgzpt.exe' in the static folder,how should i write the path

@SimulatedGREG
Copy link
Owner

Assuming Grgzpt.ext is in static/...

import { shell } from 'electron'
import path from 'path'

shell.openItem(path.join(__static, '/Grgzpt.exe'))

@lianshengxing
Copy link
Author

yes,it worked.but in the latest project,when i executed the command 'npm run build:win32',it threw an err that 'Error: EPERM: operation not permitted, symlink 'C:\Users\wzh-lian\Desktop\my-project\node_modules._7zip@0.0.6@7zip' -> 'C:\Users\wzh-lian\AppData\Local\Temp
electron-packager\win32-x64\test-win32-x64\resources\app\node_modules\7zip''

@SimulatedGREG
Copy link
Owner

Error: EPERM: operation not permitted, symlink

Looking at the error you posted, it seem you are running into a permission error. Is your terminal running in Administrator mode?

@lianshengxing
Copy link
Author

You mean that I should run the cmd as Administrator?

@SimulatedGREG
Copy link
Owner

Exactly that.

@lianshengxing
Copy link
Author

i just can not understand about that,and how to build the project

@SimulatedGREG
Copy link
Owner

Are you able to build a blank project from a fresh and untouched vue init simulatedgreg/electron-vue my-project?

@lianshengxing
Copy link
Author

I uesd 'vue init simulatedgreg/electron-vue my-project' to create a new project ,and then I executed the command 'npm run build:win32',it threw the same error

@lianshengxing
Copy link
Author

Is this error related to the '7zip'?

@SimulatedGREG
Copy link
Owner

@lianshengxing

It looks like 7zip might not have the proper permissions to complete the build step.

Unless your cmd isn't being ran as administrator, (which it should be running as administrator), I don't really know what to tell you about Error: EPERM: operation not permitted, symlink. Your system is throwing a permission error and restricting the build process from completing. I know for fact that the build process works on Windows, including ~300 users and AppVeyor CI servers. Another thing to make sure of is that your system has the proper build tools installed (https://simulatedgreg.gitbooks.io/electron-vue/content/en/getting_started.html#a-note-for-windows-users).

Other than fixing the __static bug that was discovered earlier in this thread, the rest of this thread does not pertain to an electron-vue issue. Please do not post error outputs without attempting to find solutions online, as not every issue or error log directly pertains to electron-vue.

Repository owner locked and limited conversation to collaborators Jun 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants