pid*_*row 1 npm reactjs windows-10 visual-studio-code create-react-app
当我尝试在我的 Windows 机器上创建 React 应用程序时,我不断获得未经授权的访问。我没有在 Mac 上遇到过这种行为,所以我真的不知道是什么导致了这个问题。
在 VS Code 的终端中,我运行了以下命令:
PS C:\Users\Foo_Bar\sandbox> npm install -g create-react-app
C:\Users\Foo_Bar\AppData\Roaming\npm\create-react-app -> C:\Users\Foo_Bar\AppData\Roaming\npm\node_modules\create-react-app\index.js
added 91 packages from 45 contributors in 6.923s
PS C:\Users\Foo_Bar\sandbox> create-react-app --version
create-react-app : File C:\Users\Foo_Bar\AppData\Roaming\npm\create-react-app.ps1 ca
nnot be loaded because running scripts is disabled on this system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ create-react-app --version
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\Foo_Bar\sandbox> create-react-app test-app
create-react-app : File C:\Users\Foo_Bar\AppData\Roaming\npm\create-react-app.ps1 ca
nnot be loaded because running scripts is disabled on this system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ create-react-app test-app
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS C:\Users\Foo_Bar\sandbox>
Run Code Online (Sandbox Code Playgroud)
看来npm install -g create-react-app是成功了。但是,创建实际应用程序或检查版本失败。有谁知道这可能是什么原因?
编辑:
Node和npm版本如下:
PS C:\Users\Foo_Bar\sandbox> node --version
v12.13.0
PS C:\Users\Foo_Bar\sandbox> npm --version
6.12.0
Run Code Online (Sandbox Code Playgroud)
尝试使用
npx create-react-app **foldername**
Run Code Online (Sandbox Code Playgroud)
我有同样的问题,这是更快更容易的解决方案
| 归档时间: |
|
| 查看次数: |
3455 次 |
| 最近记录: |