Neither razor pages or views support JavaScript import commands.
You need to use the npm build tool of your choice to build a script file that is loaded via the script tag. The npm build should place the compiled script in the wwwroot folder.
you could use a content copy command in the project file to copy from the node modules location to wwwroot and use the script tag.
You could also use cdn for the script tag.