Windows环境Jupyter Notebook无法访问npm和node
content
The issue may arise from using Node.js and npm through NVM (Node Version Manager), which installs them in user-specific directories. While this setup works, Jupyter Notebook or Conda might not correctly detect the npm
and node
binaries due to path resolution issues on Windows.
Troubleshooting Steps
-
Check if the PATH is set correctly for npm and node:
Your output shows:C:\Users\11543\AppData\Roaming\nvm\v20.18.0\npm C:\Users\11543\AppData\Roaming\nvm\v20.18.0\npm.cmd C:\Users\11543\AppData\Roaming\nvm\v20.18.0\node.exe
Ensure these paths are correctly added to your Windows PATH:
- Open Control Panel → System → Advanced system settings → Environment Variables.
- Under User variables or System variables, find the Path variable and ensure the following paths are included:
C:\Users\11543\AppData\Roaming\nvm\v20.18.0\ C:\Users\11543\AppData\Roaming\nvm\
-
Set npm and Node.js in Conda's environment:
Conda may not recognize the Node.js installed by NVM. To ensure compatibility, try explicitly setting the paths within the Conda environment.-
Activate your Conda environment:
conda activate base # Or your specific environment
-
Set the Node.js path manually for that session:
set PATH=C:\Users\11543\AppData\Roaming\nvm\v20.18.0;%PATH%
Alternatively, you can install Node.js via Conda to avoid the path conflict:
conda install -c conda-forge nodejs
-
-
Ensure npm works within Jupyter:
Open a Jupyter notebook and try executing the following code to check if npm is correctly detected:!npm -v !node -v
If it still fails, try starting Jupyter with a modified path:
set PATH=C:\Users\11543\AppData\Roaming\nvm\v20.18.0;%PATH% && jupyter notebook
-
Verify and Clean npm Configuration:
Sometimes, npm misconfigures itself when installed via multiple sources. Run:npm config delete prefix npm cache clean --force
-
Rebuild Jupyter Extensions (if applicable):
If you're using JupyterLab extensions:jupyter lab build
Conclusion
The problem likely lies in Conda or Jupyter not detecting the npm
installed through NVM due to path configuration issues. Adding the correct paths to your environment variables or installing Node.js via Conda should resolve the issue.
尝试了以上方法,但是暂未解决该问题;无论是用pip还是conda安装的版本,均面临此问题;不过该问题目前暂未对日常使用造成影响,因为还未安装任何扩展。
标签:npm,node,Jupyter,AppData,无法访问,11543,Conda,nvm From: https://www.cnblogs.com/smartljy/p/18475036