Sometimes there is a requirement that a local written demo needs to have a look with colleagues on the LAN, or a mobile demo needs to debug on the phone, or the demo needs to use es6 syntax, the webpage can not be opened in HTML file, you need to start a local Node environment, the specific steps are as follows:
1, NPM init
A package.json file will appear in the folder
2, NPM install
Install HTTP-Server and Anywhere
npm install http-server -g
npm install -g anywhere
Copy the code
After installing, type Anywhere -p 8085
Q&A
Anywhere: Cannot load file C: Users\1\AppData\Roaming\ NPM \anywhere. Ps1 because scripts are not allowed to run on this system. For more information, please refer to the about_Execution_Policies https:/go.microsoft.com/fwlink/?LinkID=135170. Location line :1 Character :1 + ~~~~~~~~ + FullyQualifiedErrorId: UnauthorizedAccessCopy the code
I checked the Internet and said there was a problem with the execution strategy. The solution is as follows:
Open this folder as an administrator
The get-executionPolicy is Restricted, which proves to be disabled
Execute the set-executionPolicy remotesunet
If you do not have administrator rights to run the following command:
Set-executionpolicy: Access to registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" was denied. To change the execution policy for the default (LocalMachine) scope, start Wi dows PowerShell using the run as administrator option. To change the ExecutionPolicy for the CurrentUser, run "set-executionpolicy -scope CurrentUser". Location: 1 character: 1 + set - ExecutionPolicy RemoteSigned + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + CategoryInfo: PermissionDenied: (:) [Set-ExecutionPolicy], UnauthorizedAccessException + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommandCopy the code
You can run the set-executionPolicy RemoteSigned -scope CurrentUser command
Then, the get-executionPolicy state becomes Restricted
At this time, execute anywhere -P 8085, and you will be perfectly successful